I am using an FRDM k64 Arduino, and developing a TCP/IP client on it. It works as follows. There is a circular queue that stores data. Periodically that queue gets data put in the queue from external sensors via an interrupt. During free time I check to see if there is data in the queue, if there is data, empty the queue and write the data to a server. To do this I use FreeRTOS plus the netconn API that comes with LWIP. I have 1 thread called TCP_Thread that creates a connection, and connects to my server. I then have an infinite while loop that checks the queue and runs netconn_write if there is data (yes I handle looping back on the queue). After few hundred sucessful writes to the server (currently just a C# server on a PC that writes the data to a screen) my MCU crashes. I end up in the default ISR, which points to a bus fault.
If I lower the number of netconn_write calls by increasing the minimum ammount of data in the queue before we bother to write to the server (for example need 100 bytes vs 1 byte to call netconn_write) the ammount of time the MCU lasts between crashes goes up (havent checked exact number of calls, but my gut says it will be simmilar). Is there something I am missing here? It seems I am running out of memory and crashing, but because LWIP is an API I really don’t have an easy way to malloc for it/shouldn’t I not need to because all resources should be freed after a local function (netconn_write) is called?