We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi all, I have a problem with the ISR of TIMER0. I'm using keil uVision2 and my target is SIlicon Laboratories C8051F040.
I've tried to make a very simple project in assembler to use Timer0 ISR (below you will find the relatives code) and it works fine.
If I try to translate this project in C, the ISR is called just a few time (around 10 or 11 times) but after this, it is never called!
But... if, instead of Timer0, I use Timer1, all work fine both in C and in Assembler
I can't understand why? There is someone wich can help me?
NOTE: Is not important the reload value so i don't set it, and although if I set this value the behaviour not change. NOTE: Timer0 is a 16-bit timer NOTE: In the examples below I've hided the not relevant code like oscillator init, port init,...
-------------- ASSEMBLY CODE: --------------
... ... ... ;TIMER_0 Overflow ORG 0x000B LCALL TIMER0_INT ... ... ... TIMER_INIT: NOP ;------ ;TIMER0 ;TIMER1 ;------ MOV SFRPAGE, #TIMER01_PAGE MOV TCON, #01000101b MOV TMOD, #00100001b ... ... ... INTERRUPTS_INIT: MOV IE, #10010111b MOV IP, #00000000b MOV EIE1, #00001000b MOV EIE2, #01000000b MOV EIP1, #00001000b MOV EIP2, #00000000b ... ... ... MAIN: MOV SFRPAGE, TIMER01_PAGE SETB TR0 ;START TIMER JMP $ ... ... ... TIMER0_INT: RETI
------- C CODE: -------
... ... ... void Timer_Init() { SFRPAGE = TIMER01_PAGE; TCON = 0x45; TMOD = 0x21; CKCON = 0x18; SFRPAGE = TMR2_PAGE; TMR2CN = 0x04; TMR2CF = 0x08; SFRPAGE = TMR3_PAGE; TMR3CN = 0x04; TMR3CF = 0x08; SFRPAGE = TMR4_PAGE; TMR4CN = 0x04; TMR4CF = 0x08; } ... ... ... void Interrupts_Init() { IE = 0x97; EIE1 = 0x08; EIE2 = 0x40; EIP1 = 0x08; } ... ... ... void main(void){ Timer_Init(); Interrupts_Init() ... ... ... SFRPAGE = TIMER01_PAGE; TR0 = 1; //START TIMER while(1); } void timer0_int(void) reentrant interrupt 1 { }
Anyhow in your code you will generate T1 interrupts and you show no T1 ISR, is there one in the assembler and not in the C
The above is a question in my previous post and the sequence in debugging, be it 'live' or via a forum, is questions and answers till the right question finally emerges.
Erik