weird situation with DELAY

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
r_romeo
Posts: 54
Joined: Wed Nov 02, 2011 3:57 pm
Has thanked: 14 times
Been thanked: 3 times

weird situation with DELAY

Post by r_romeo »

Hi
I am programming a simple code that sends a CAN signal every second and the receiver , once has check got something, turn on a LED for 500 miliseconds.
the problem is that if i use "DELAY" either for sending or turning on the LED, the time in real world does not match the programmed one.
I was able to overflow the problem using timer interrupts but still bugs me that I am not able to use "DELAY" the wich for me would be a more "elegant" way to do it.
Anyone knows why this is happening?
Here I attach the file I am doing, the sender , fixed with timer now sends the CAN signal every second, but the receiver turns on the LED for about 0,36 secs instead of 0,5 as specified in the code
watchdog is off

Thanks
Attachments
can-test-1-tx.fcf_pic16
transmiter with delay problems
(8 KiB) Downloaded 258 times
can-test-1-rx.fcf_pic16
receiver with delay problems
(9.5 KiB) Downloaded 261 times
can-test-timer-interrupt-tx.fcf_pic16
transmiter with fixed interrupt
(8.5 KiB) Downloaded 260 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: weird situation with DELAY

Post by Benj »

Hello,

For delays to be correct please ensure that the clock speed setting in the project options is correct for the oscillator frequency you are using. Your config settings could also potentially be at fault.

r_romeo
Posts: 54
Joined: Wed Nov 02, 2011 3:57 pm
Has thanked: 14 times
Been thanked: 3 times

Re: weird situation with DELAY

Post by r_romeo »

Problem solved !! , thank you!!

You are right , I discover that when the "auto clear watchdog" (View>Project options) is enabled, the delays are affected, It does not matter if watchdog is enabled or not, also I can see that is not a reset.
I made a simple on/off LED code and both, the on and off periods are reduced from 500 (ms)/500 (ms) to 370 (ms)/370 (ms)
but still I dont understand why this is happening

any ideas?

Post Reply