|
Re: Robot Timing Code
"is there a way to disable the watchdog timer?"
No. Also, I'm not even sure there is a WDT used in the user processor -- a check of the program memory map only showed a CLRWDT in the memory loop used to clear/initialize ram to zero at startup. But, its possible I missed something.
Its been a while since I looked at the default code on the user processor.
There are two PIC processors - a master processor and a user processor. First teams are programming the user processor. Default master code is loaded on the master processor.
The master processor is where all but PWM13-15 are connected. The master processor is designed to control all the motion of the robot such that if something goes wrong, it can detect the problem (like the user program on the user processor is whacked out) and stops all output. The OI comes into this processor too.
There is a data stream between the master and user processor over the SPI (serial) bus. This is a bi-directional serial 1-bit wide bus. The data stream is constant. The master is constantly sending the next rx data with OI information on the output stream and is simultaneously recieving the tx data from the user with the updated motor information.
On the user processor, the high priority interrupt routine services the SPI bus. It is constantly sending and recieving data into double buffered recieve and transmit data structures. It is filling up the 'A' rx buffer, while the 'B' rx buffer is sitting there for Getdata() to access. When this interrupt routine has recieved the last of the current 'A' rx data structure, it swaps buffers and sets a status flag indicating new rx data is available. It then starts filling up the 'B' rx buffer. A call to Getdata() will copy out the 'A' or 'B' buffer - whichever has the current completed rx data structure.
Calls to Putdata() place the tx data from the user into the send buffer not currently in use by the interrupt routine. You can repeatedly call Putdata() all you want, but until the high priority interrupt swaps buffers at a data structure boundary - the data doesn't won't go anywhere.
I don't recall if it is the lack of a Getdata() call or something else, but the end result is the master processor is able to detect that the user processor has flaked out and isn't consuming/updating data as it should. It asserts the !MCLR (master reset) on the user processor and holds it in the reset state giving you the red light of death. There is no way to prevent this from the user processor other than to do the Getdata/Putdata often enough to avoid the master processor killing your user processor.
I believe the IFI site has documentation that describes all this.
Last edited by dcbrown : 19-01-2008 at 14:21.
|