Problems with TMR1 interruption

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Fer_taca
Posts: 91
Joined: Fri Oct 27, 2017 9:50 am
Has thanked: 13 times
Been thanked: 10 times
Contact:

Problems with TMR1 interruption

Post by Fer_taca »

I'm starting to use Flowcode and he did a basic example: turning on and off a led, using delays. The next step was the use of interruptions.

To do this, he chose to use the TMR1 to create a 1second timing. When performing the operation: oscillator of 20MHz, internal advance and prescaler of 1: 8. According to that Flowcode indicates to me that the interruption occurs every 9,5387 or what is the same 0,10483 milliseconds.

If you want to reach 1 second, within the interrupt routine I create a counter up to 10 so I should have the second of the timing plus a small error.

If I running the project simulation, I can see the output (led), associated with a pin, that changes very quickly, several times per second. However, if I change the counter to a value of 200, the output is already seen to change more or less to the second.

Is this a problem of the simulator or of someone who does not know how to do it?

Thank you very much

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Problems with TMR1 interruption

Post by kersing »

Timing in simulation is not accurate, especially when using interrupts. You will need to test on hardware for exact timing.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Fer_taca
Posts: 91
Joined: Fri Oct 27, 2017 9:50 am
Has thanked: 13 times
Been thanked: 10 times
Contact:

Re: Problems with TMR1 interruption

Post by Fer_taca »

Thanks for your reply.
In addition to the simulation that has become clear to me, I would like to know if the calculations I have made would be correct or not.

Post Reply