Discussion in "8051 Discussion Forum" started by    wounder    Feb 10, 2020.
Mon Feb 10 2020, 03: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 //[email protected]=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 //[email protected]=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, 03:43 AM ]
Fri Feb 21 2020, 05:05 PM
#2
Did you sort out your problem?

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Mar 25 2020, 09:39 AM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 06:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 08:55 AM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 12:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 11:58 AM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 05:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 01:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 02:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me
Tue Dec 17 2019, 08:44 AM
Devangi
hello..i am programming industrial timer using 8051 with 24lc64 eeprom. i have query in storing the 3 diff value in eeprom with enter button. can anyone share c code ?
Tue Dec 17 2019, 05:30 AM
Andrius
Hello. Can anyone share the code in Bascon and scheme in Proteus?

Downloads

Comments

OliverKiz
Mon Apr 06 2020, 07:54 PM
Nikolaynom
Mon Apr 06 2020, 09:13 AM
Paulinewop
Sun Apr 05 2020, 10:33 PM
NormanJeops
Sun Apr 05 2020, 03:26 AM
NoraHar
Sat Apr 04 2020, 09:03 PM
codr
Sat Apr 04 2020, 04:45 AM
ElizabethJuich
Wed Apr 01 2020, 09:24 AM
MichaelVaf
Tue Mar 31 2020, 07:49 AM

Online

Guests: 39, Members: 0 ...

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

Members: 38145
Newest member: OliverKiz
Forum Activity
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...
sarrahjuzar Avatar
Posted By sarrahjuzar
Wed Feb 19 2020, 04:24 AM
I have a gsm module sim900a and dht22 connected to...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Feb 18 2020, 04:52 PM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:59 AM
figureyang Avatar
Posted By figureyang
Tue Feb 18 2020, 04:50 AM
wounder Avatar
Posted By wounder
Mon Feb 10 2020, 03:32 AM
From below sample code for nuvoton 8051 timer0 mod...
Just4Fun Avatar
Posted By Just4Fun
Sat Feb 01 2020, 09:20 AM
If you want to use a CH55x MCU there isn't any adv...