Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

USB low-full-high speed peripherals Forum Discussions

wewuc_3947566
Level 1
Level 1

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;

   }

0 Likes
1 Solution
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

View solution in original post

0 Likes
1 Reply
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

0 Likes