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
weird situation with DELAY
Moderator: Benj
weird situation with DELAY
- 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
- 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
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: weird situation with DELAY
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?
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?