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

Sun Dec 05 2021, 09:58 PM
Sophia Scott
Click the link below to view the message and reply to her.
Sun Dec 05 2021, 07:22 PM
Kia
Hello there! This post could not be written much better! Going through this article reminds me of my previous roommate! He always kept preaching about this. I most certainly will send this post to him. Fairly certain he'll have a very good read. Thank you for sharing! https://comprarcialis5mg.org/it/cialis-5-mg-effetti-collaterali/ http://beans.s24.xrea.com/cgi-bin/apeboardp/apeboard_plus.cgi effetti collaterali del cialis 20 mg
Sun Dec 05 2021, 06:59 PM
Amelie
Heya i am for the first time here. I came across this board and I in finding It really useful & it helped me out a lot. I hope to give something again and aid others like you helped me. https://comprarcialis5mg.org/it/comprare-spedra-avanafil-senza-ricetta-online/ http://bsiuntag-sby.com/halkomentar-175-posting-blog-melalui-microsoft-576.html spedra ravenna
Sat Dec 04 2021, 07:47 PM
cjeeoeajau
hotlnflsty
Sat Dec 04 2021, 03:07 PM
xeokayweqj
kcujqxnltb

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: 61, Members: 0 ...

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

Members: 38215
Newest member: Mirza123