How do I implement a cog watchdog
I am using BS2 function's "debugin" to get input. However, I would like it to time out if the user doesn't enter their name.
inside the code it has a reference to implement a cog watchdog, using the example... but I don't see the example.
Does anyone know how to do this?
Thanks in advance
inside the code it has a reference to implement a cog watchdog, using the example... but I don't see the example.
Does anyone know how to do this?
Thanks in advance

Comments
waitpeq(Mode << PIN, |< PIN, 0) ' Wait for idle waitpne(Mode << PIN, |< PIN, 0) ' WAit forThese are used because they put the cog running them into a low power state, saving power. They're equivalent to the following loops:
repeat until (Mode << PIN) & |< PIN ' Wait for idle repeat while (Mode << PIN) & |< PIN ' Wait for beginning of start bitTo add a timeout, define another local variable "time" after "BR" in the declaration of SERIN_CHAR and define a constant "timeOut" at the beginning of the object in one of the CON sections like "timeOut = 10000" for a 10 second timeout between characters. You'd then do:
waitpeq(Mode << PIN, |< PIN, 0) ' This could still be used since it waits for idle time := CNT ' Save start of timeout period repeat while (Mode << PIN) & |< PIN ' Wait for beginning of start bit if (CNT - time) > timeOut*(CLKFREQ/1000) ' Has timeout (in milliseconds) expired? return -1 ' Return a -1 to indicate that a timeout occurredNote that you also have to modify the SERIN_DEC, SERIN_STR, and other SERIN_ routines to use a -1 as a buffer terminator in addition to a return (13) code or they'll store the -1 in the buffer (as a 255) and keep calling SERIN_CHAR which will continue to timeout thus filling up the buffer.
Also note that the timeout is limited to about 50 seconds with an 80MHz system clock.
Thanks again!!!