Discussion in "8051 Discussion Forum" started by    wounder    Feb 10, 2020.
Mon Feb 10 2020, 08:32 AM
#1
From below sample code for nuvoton 8051 timer0 mode 0, the isr interval is calculated is 1ms,
its work. but how can I calculate the minimum isr timer interval for 16mhZ frequency.?

#define TH0_INIT 0x1A //1.0ms@XTAL=16MH
#define TL0_INIT 0xEC

while loading these hex values gets 1ms Isr interval. I was tried 5-microsecond calculation for timer 0, but not get the correct 5uS interval.

#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"



#define TH0_INIT        0x1A //1.0ms@XTAL=16MH
#define TL0_INIT        0xEC
#define TH1_INIT        0xD7 
#define TL1_INIT        0x0C


/************************************************************************************************************
*    TIMER 0 interrupt subroutine
************************************************************************************************************/
void Timer0_ISR (void) interrupt 1          //interrupt address is 0x000B
{
    TH0 = TH0_INIT;
    TL0 = TL0_INIT;    
   											// GPIO toggle when interrupt
}
/************************************************************************************************************
*    TIMER 1 interrupt subroutine
************************************************************************************************************/
//void Timer1_ISR (void) interrupt 3          //interrupt address is 0x001B
//{
//    TH1 = TH1_INIT;
//    TL1 = TL1_INIT;   
//  P12 = ~P12;																	// GPIO toggle when interrupt
//}
/************************************************************************************************************
*    Main function 
************************************************************************************************************/
void main (void)
{
	//TMOD = 0XFF;
	Set_All_GPIO_Quasi_Mode;
	TIMER0_MODE0_ENABLE;                        //Timer 0 and Timer 1 mode configuration
//	TIMER1_MODE0_ENABLE;
    
	clr_T0M;
	clr_T1M;
    
	TH0 = TH0_INIT;
	TL0 = TL0_INIT;
//	TH1 = TH1_INIT;
//	TL1 = TL1_INIT;
    
	set_ET0;                                    //enable Timer0 interrupt
	//set_ET1;                                    //enable Timer1 interrupt
	set_EA;                                     //enable interrupts
	
	set_TR0;                                    //Timer0 run
	//set_TR1;                                    //Timer1 run

  while(1)
	{
		
	
}
}


[ Edited Mon Feb 10 2020, 08:43 AM ]
Fri Feb 21 2020, 10:05 PM
#2
Did you sort out your problem?

Get Social

Information

Powered by e107 Forum System

Conversation

Tue Sep 22 2020, 12:02 PM
Nicole Dawson
Nicole Dawson
Thu Jun 11 2020, 06:27 AM
anudee
sir could please send the code for I2C and wifi interfacing with 8051
scena
Tue May 19 2020, 10:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 07:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 01:39 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 10:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 12:55 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 05:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 04:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 10:12 AM
Pearl Olin
Hello,

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 98, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123