Memory in RCM6700

I am using the RCM6700 and trying to send 10100 bytes through tcpip. In a local function, I created a local buffer array which size is 10100 bytes:

char temptcpbuf[10100];

  1. When I try to clear this buffer with using
    memset(temptcpbuf, 0x00, sizeof(temptcpbuf));
    the processor is freeze and report timeout (when running in debug mode).
    Can I create a buffer size this big?

  2. I try to read the data from a remote device through I2C:
    I2CRead(ADDRESS, 0, temptcpbuf, 10100);
    Also the processor is freeze and report timeout.
    The I2C timeout is 10ms. Tried to set longer to 40ms but still has the issue.

When I reduce the buffer size to 8000, all the issue seems gone.
Can you suggest a solution for this?


When you create a local buffer in your function, it goes onto the stack, which is probably about 4KB. What if you limited the buffer to 1KB and just re-used it?

If you need that size, you can declare your buffer as static far char temptcpbuf[10100]; in your function, or declare it as a global outside of the function and remove the static attribute.

But I see that I2CRead() doesn’t work with far pointers, so maybe reducing your buffer to 1KB (so you don’t overflow the stack) and reusing it would work for your design.

If you absolutely need a buffer that large, you might have enough root memory available to leave the far out of the declaration as either a static buffer in the function or a global buffer.

Thank you for the reply. Is it possible to increase the stack size from 4k? Reusing the buffer will work but it will increase the overhead on timing.


No easy way to increase the stack size – you’re better off declaring this as a global (or static) variable. Depending on what else your program is doing, you might not have enough root (64KB address space) data space for the variable. If this is a bare bones program though, you should be just fine.