Page 1 of 1

Timer Interrupt Prescaler Rate

Posted: Wed Jan 26, 2022 9:03 am
by liudeqiang_2008
Hello,

I use a main loop to turn on and turn off LED1 every 1 second. Using a timer interrupt to call Macro LED2_Blink.

In the timer interrupt setting, I use 1:1024 Prescaler Rate to set the Interrupt Frequency to 61.035 HZ.
As I understand, in every 1 second the timer interrupt will active 61 times.

In the Macro LED2_Blink, I made a Variable :Count , to count the active times of timer interrupt, if the Count goes up to 61, I will turn on/turn off the Led 2. After that ,the Count will be set back to 0.

Than the 2 Leds should blink almost in same step, every 1 second turn on or turn off.

But in the simulation mode, the Led 2 is much fast than Led 1.
I have attached my program, could you please support me for this?

Thank you in advance!
Best regards,

Adam.

Re: Timer Interrupt Prescaler Rate

Posted: Wed Jan 26, 2022 10:48 am
by BenR
Hi Adam,

Timings for interrupts in the simulation will not be accurate, mainly bacause they rely on Windows based timings which are not timing accurate. On the actual microcontroller the timing should be much more as expected.

Re: Timer Interrupt Prescaler Rate

Posted: Thu Jan 27, 2022 5:02 am
by liudeqiang_2008
Hi Ben,

Thank you for your reply, I will test it in microcontroller.

BR
Adam