Quantcast
Channel: How to Disable/Delay the watchDog Timer for a certain Task in an embedded system - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Lundin for How to Disable/Delay the watchDog Timer for a certain Task in an embedded system

$
0
0

Can I disable the watchdog timer for this specified function (which must not be disabled but just for testing purpose)? It is possible to use more timeOut for the watchdog on that specified function?

You should never disable the watchdog anywhere in your code.

It might not even be possible, on the MPC5x families you typically set up the watchdog once, and then for safety reasons all watchdog registers turn to read-only registers.

Must I develop another task with a big delay in other to run the algorithm? But the problem is that the algorithm need to be synchronised with the 1ms task since we are receiving CAN commands.

Ideally you should only service the watchdog from one single location in the program. Your CAN peripheral will be FlexCAN, which has a lot of available "mailboxes" for CAN messages. In most cases, you shouldn't need to poll it, but a flag will be set when the desired message arrive.

So it isn't obvious to me why you would need a delay to wait for them. Simply do:

void the_task (void){  wdog_refresh();   ... // do other things  if(can_message_available)  {    // do something with the message  }  ... // do other things}

rather than

// BAD:while(!can_message_available)  ; // do nothing

Even if you need to use the CAN as FIFO and poll it repeatedly, you would still use the same approach. You'd just have to ensure that the task runs often enough that there will never be an overflow in the FIFO buffer.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>