This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What should be the maximum size of a variable that we can use

Hi all, In my project I have a structure its length was about 2KB, I'm saving it as a static variable after using this I come across with a weird behavior from the board, Some times its hang up when I gets disconnected from the phone, and I'm able to resolve that by changing the compiling order of .c files in makefile(not sure how could it effect). And now I'm seeing it works fine if I don't write data to uart and getting hang when I'm writing data through uart,

I felt like it may be because of some segfault(correct me if I'm wrong). And I'm really wonder to know what should be the maximum size of a static variable that we can use in a project

PS: My board configurations were nrf51822 with 16KB of RAM and 256KB of flash and I'm using SDK11 on the board I'm using 2KB for stack and 0bytes for Heap

I'm attaching my .map files. My code with this mapfile1.map mapfile getting hanged on disconnected, and code with this mapfile mapfile 2.map resolves issue when disconnects but getting hanged on writing data to uart

The only change that I made for both two is changing the order of .c files in makefile like order1.png to order2.png no changes in code

here is my sensor_conditioner.c and custom_app_uart_fifo.c

EDIT: I did some sort of debugging and found the reason for crashing the app is because of changing value of a variable that storing call back handler address m_application_table[0].ntf_cb but not sure how could it happens. I'm attaching my resultsimage description, image description

We can observe before calling the function ble_sh35_update_sat_temp(), m_application_table[0].ntf_cb points to a valid call back address 0x1d4f5 but just after calling that function the value getting changed to 0x20001d04 this value keep on changing while tracing and points to some undesired location, that's why when I disconnected from the phone it should call this call back function but it encounters a hard fault can any one understood what should be the reason for it and for small info m_application_table located at address 0x200035B4 in my map file and end address of RAM is 0x20004000 and the start address of RAM is 0x20003800

Thanks in advance

Related