cancel
Showing results for 
Search instead for 
Did you mean: 

USB Low-Full-High Speed Peripherals

New Contributor

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
Reply
1 Solution
Moderator
Moderator

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
Reply
1 Reply
Moderator
Moderator

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
Reply