I have implemented the TCPnet library and a simple routine to send an email to myself. It works, however only about 50% of the time; one of several things causes it to fail: it doesn't ever receive and IP address and gets assigned 169.254.x.x and than nothing works, or it gets a valid IP but then either has a server timeout error or email failed to send error.
When it works it works fine and all data is transferred and email comes through correctly and to the correct address. But half the time it fails. I have the timer tick already set to max of 10ms so it is going as fast as the library will allow.
Any ideas as to why it may not be working all of the time?
You did not mention a device type which you are using. For Cortex-M devices you can use ITM as a debug print channel. So you can make a very fast print over ULINK2 or ULINKpro, and see that in uVision debug window (uVision Debug->View->Serial Windows->Debug (printf) Viewer).
ITM is a Cortex-M core extension, it does not need any peripheral. To use it, you need uVision and a connected ULINK2/pro debugger. You can also capture debug output to a text file from within uVision debugger.
With this code, you can print debug messages to ITM from TCPnet:
int fputc (int ch, FILE *f) { if ((ITM_TCR & ITM_TCR_ITMENA_MSK) && (ITM_TER & (1UL << 0))) { while (ITM_PORT0_U32 == 0); ITM_PORT0_U8 = (uint8_t) ch; } return (ch); }