STM32F030C8Tx was a hard fault when using SPI (HAL)
- January 16, 2019
- 9 replies
- 4882 views
Hi everyone,
My name is Chinh, I am working on stm32f030c8t6 for my project. I am using SPI1 to interface with an RF module. This program run very good when I implement on stm32f103c8t6, to save money I decide to switch to stm32f0 which have a lower cost than F1. Unfortunately, I have a big problem that I can't understand and I have ever seen during the working time on stm32 MCU series.
I used a pointer (ui8) to point an array and if I change the value of pointer such increasing one by one after every transmission that goes to hardfault handle when putting data to DR register.
Examples:
uint8_t table[] = {0x06, 0x02, 0x52, x64, 0x01, 0x00};
uint8_t rx[10];
uint8_t *p;
p = table;
TransmitReceive(spi, p, rx, 2, timeout);
p++;
TransmitReceive(spi, p, rx, 2, timeout); -> hardfault
If I change a bit
TransmitReceive(spi, p, rx, 2, timeout);
p++;
TransmitReceive(spi, p, rx, 1, timeout);
-> No hardfault
Or:
TransmitReceive(spi, p, rx, 1, timeout);
p++;
TransmitReceive(spi, p, rx, 1, timeout);
-> No hardfault
I attached a project with this situation below. It uses HAL library and Keil C v5. If you have a kit development or any PCB, you could run to check that. It's very weird
Addition, SPI1 and SPI2 also have the same result
Does anyone help me?
Thanks a lot!
