- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to control the timer0 and use its interrupt. When I set TR0=1 before the while loop. The interrupt works. But if I try to control the TR0 and want to control the interrupt in while loop, it looks that interrupt doesn't work. I know the TR0 is set to 1, but interrupt don't work.
while(1)
{
get the command first then
case 0x82:// Run command;//0x82
TL0=0xc0;
TH0=0X03;
TR0=1;
command=0;
break;
default:
break;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please recheck few things. The code snippet is in application file and not in the fw file.
Is the application code entering the case statement where you have initialized the timer values and have started the timer.
How often is the code flow entering the respective case statement? If the case statement is being executed again even before the timer 0 is overflowed (interrupt is generated when the timer register values overflows) then the timer values are reset and the interrupt is not generated.
You can try giving a higher value to the timer registers so that the values overflow quickly and the interrupt is generated.
Best Regards
Yatheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Please recheck few things. The code snippet is in application file and not in the fw file.
Is the application code entering the case statement where you have initialized the timer values and have started the timer.
How often is the code flow entering the respective case statement? If the case statement is being executed again even before the timer 0 is overflowed (interrupt is generated when the timer register values overflows) then the timer values are reset and the interrupt is not generated.
You can try giving a higher value to the timer registers so that the values overflow quickly and the interrupt is generated.
Best Regards
Yatheesh