cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 global buffer getting corrupted

yafisdamda
Associate II
Posted on May 05, 2018 at 16:50

Hi All.

I am using STM32F030 as my development platform. I have a RF module connected to UART2.

The uart is operating at 9600, UART_RX is configured as interrupt. Things work fine, but sometimes a global buffer defined as static in some other file is getting corrupted with values received over UART.

Any inputs on finding the issue will be of great help?

Thanks.!

#stm32 #stm32-uart #memory-corruption
3 REPLIES 3
Posted on May 05, 2018 at 17:23

Watch the pointer used in the receiving UART function. Seems like it exceeded boundaries of the memory where you would like to store data received from the UART.

Share the code to understand the role of the buffer vs place in the memory you want to store UART received data.

Posted on May 05, 2018 at 20:50

You're going to need to walk your code an identify memory usage and writes which could corrupt memory or go out of bounds.

You'd want to add checks and breakpoints in critical areas to sanity check pointers and indexes to ensure they don't go out of range, and secondary checks of the buffer getting corrupted to trap the failure as quickly as possible after it happens so you can zoom down and focus on specific portions of your code.

Make sure your stack is sufficiently large to manage your usual call tree, and any the would occur from interrupts. Quantify how much stack you are currently using.

Check memory as you enter and leave interrupts.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on May 07, 2018 at 09:03

HI.

Thanks guys..!!!

Apparently i was getting UART overrun error and data getting missed. Due to this the uart rx buffer overflowing.

There was no overflow checks, my bad..!!!

I am still debugging...will update if i find anything.

Thanks..!!