Can I reset Microchip's TCP/IP stack without reseting the board?
Question
I'm working with Microchip's free TCP/IP (version 4.55) stack on an 8-bit micro-controller.
I'm trying to reset the stack without doing a full board reset with asm("RESET").
Any ideas on how to restart this Stack.
UPDATE
I reset the stack with the following steps
- Toggle the reset pin to on the Microchip Ethernet chip
- Call StackInit();
- Manually reset the UDP announce state machine
This seems to recover from the fatal SPI errors I encountered.
Solution
Call StackInit(). That function reinitializes all the sub-modules (TCP, UDP, SMTP, etc.). It will also clobber all of the TCP and UDP socket you have open, so you will have to re-open the sockets you want to use.
As a side note: I followed the thread on the Microchip forum. I was also getting strange resets in my TCP stack. It ended up being a stack overflow. Put some variables at the top of your stack.
#pragma udata stackoverflow = 0xE00
UInt32 StackUpperBound[8];
#pragma udata
Initialize these variables at the beginning of main() and put a breakpoint at the beginning. See if these variables are being overwritten.
OTHER TIPS
I am totally not familiar with the Microchip stack, but unless the stack is designed to be restarted, I doubt you will be successful.
If all the buffers and structures are statically allocated, then in theory, you could call the initialization routines to "restart" the stack (assuming it does a re-initialization of the structures).
If it uses dynamic buffers (malloc), then I believe you would be out of luck.