cancel
Showing results for 
Search instead for 
Did you mean: 

Busfault not generated on STM32F2

llo
Associate
Posted on February 18, 2014 at 22:18

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-busfault
3 REPLIES 3
Posted on February 19, 2014 at 01:58

What's mapped at ZERO?

Try

  int *ptr = (int *)0x20200000;
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
llo
Associate
Posted on February 21, 2014 at 00:17

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

Lawrence

chen
Associate II
Posted on February 21, 2014 at 11:08

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.