2014-02-18 01:18 PM
I am running the standard peripheral demo code on an STM3221G evaluation board (for STM32F2 MCU).
However when I tried to force a busfault by writing to an invalid address, nothing happened and the program just moved on! For example the following code inserted at the beginning of main() would cause an BusFault exception on STM32F3Discovery board, but NOT on the STM32F2 eval board. int *ptr = (int *)0x0; *ptr = 1; I am perplexed since I believe we do not need to explicitly enable busfault for precise/imprecise errors (unlike division by zero.) Please help since trapping invalid memory access is important to our application. Thanks Lawrence #stm32f2-busfault2014-02-18 04:58 PM
What's mapped at ZERO?
Try int *ptr = (int *)0x20200000;2014-02-20 03:17 PM
I tried writing to 0x20200000 and it indeed raised a busfault. However 0 is mapped to code, and I thought writing to code space would also raise a busfault. It faulted on the STM32F3Discovery board but did not on the STMF221G Eval board, which I found odd.
I also tried writing to 0x1FFFFFF0, which is just below the SRAM region. It did not raise any faults either. Thanks Lawrence2014-02-21 02:08 AM
Hi
Be careful. NULL is often defined as 0. Not sure using 0 to cause a bus fault is a good idea. Finding a memory region which always causes a bus fault on all processors is also tricky. On STM32 there is address banding.