views:

617

answers:

3

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

  1. Toggle the reset pin to on the Microchip Ethernet chip
  2. Call StackInit();
  3. Manually reset the UDP announce state machine

This seems to recover from the fatal SPI errors I encountered.

A: 

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.

Benoit
A: 

I also asked the same question on the Microchip forum.

http://www.microchip.com/forums/tm.aspx?m=408135&mpage=1&key=&#408365

Justin Tanner
+2  A: 

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.

Robert
I've tried calling StackInit(), but can't bring back my TCP sockets after doing this.Where did you put your blank array StackUpperBound? in your main file, or somewhere in the stack.
Justin Tanner
Also, any reason you created your own block? ( stackoverflow )
Justin Tanner
In the linker file, my stack was located at 0xD00 and was 0x100 bytes long. So putting my variables are 0xE00 is at the top of the stack. I always give names to any blocks I define just as a habit. In main(), I have a loop to intialize StackUpperBound to DEADBEEF.
Robert