We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello All,
I am trying to figure out how best to write a sequential code execution monitoring diagnostic for my 8051 project. I want to be able to prove that the code execution has hit all of my 8 tasks before resetting the watchdog timer.
Each task is done at 1.25msec time intervals, they must happen in order, and it takes all 8 to complete the sequence.
It seems like there might be a way to encode a single byte that's end value proves I went through all 8 states and in the right order.
My first instinct is to simply advance a counter, but that can be fooled if stuck in the same task the right number of times. Maybe if I folded in an 8-bit CRC to a register?
Any suggestions are appreciated. (except for the condesending type)
Set a bit in a byte for each task (you have 8) when the number is 0xFF (255) each task has been completed.
That's the simplest method I can think of (you can tell which task is not completed also). Each task sets the bit. When the watch dog is kicked you reset the byte.
Stephen
Not sure why I couldn't think of that!
Thanks!
That will show that all tasks have run, but not necessarily that they ran in the correct order.
However, if you check whether the bits of earlier tasks have already been set, and only set the tasks bit if the earlier tasks did already run and the later tasks did not, you might get an indication of the correct order.
Yes, I was just contemplating that issue.
i.e. what happens if I did a state twice. Checking almost seems mandatory.
Let task 1 set the 0x01 bit if the original value is 0. Let task 2 set the 0x02 bit if the original value is 1. Let task 3 set the 0x04 bit if the original value is 3. ... Let task 8 set the 0x80 bit if the original value is 254.
As an addendum, you could let a task that finds the incorrect value instead set an error flag - either because it has run more than once, or in the wrong order.