9 years, 1 month ago.

LPC1768 freezes when memory pool is full

Hi all,

I'm having this problem where the LPC1768 (on a UBLOX C027 dev board) freezes when the memory pool is full. My program has an architecture very much similar to the example for Memory Pool on the RTOS page: https://developer.mbed.org/handbook/RTOS#memorypool . One thread collects GPS data and one thread transmit data via GPRS to my remote server.

The problem arises when I lose the connection to my remote server. At this point the GPS data is still appended to a queue , which is governed by a fixed size memory pool.

Queue and Memory Pool declaration

typedef struct {
char gps_mess[128];
}
MemoryPool<message_t , 16> message_pool;
Queue<message_t , 16> message_pool;>

When the memory pool is full, the LPC1768 freezes. My workaround is have a flag to check whether or not the GPRS connection is still good. If the connection to the remote server is busted then don't append anything else to the queue.

So my question is:

1 - Is there another way to check if the memory pool is full?

2 - Why should my program become frozen? I'm using a queue anyway, so any new message should be written into the queue like a ring buffer. But from the evidence I'm seeing, this is not consistent with my understanding. An explanation is much appreciated.

Many thanks,

1 Answer

9 years, 1 month ago.

The documentation says that thhe alloc returns a NULL pointer when there is a error . Do you test this ? (the sample program forgets to do this test)

Thanks for the suggestion. I tried this check before putting a message into the queue but after 16 messages, any message after that is not put into the queue. The alloc function always return zero even though the messages are consumed in another thread (ie. the messages appear on the remote server and free function is called ). In general, the LPC1768 doesn't freeze but new messages are not appended into the queue.

posted by Kevin Le Dinh 17 Mar 2015

Hi, got it working with the alloc check. Haven't exactly followed the example :)

posted by Kevin Le Dinh 17 Mar 2015