Skip to main content
TBhil.1
Associate II
July 12, 2021
Question

Hello! I am currently working on STM32F205 using Keil uvision. I have been getting an INVPC hard fault repeatedly. So I increased the stack size from 0x400 to 0x800 and set the stack alignment bit in CCR register at power on. This removed the INVPC h

  • July 12, 2021
  • 2 replies
  • 1091 views

fault but instead I got Precise Bus Fault with following stack frame :

R0 = 28000134 R1 = 1 R2 = 40000000 R3 = 1 R12 = ae60cd5 LR = 80015b9 PC = 80015be PSR = 2100002c- FSR/FAR: CFSR = 8200 HFSR = 40000000 DFSR = 0 AFSR = 0 BFAR = 28000130

By disassembling the code, I found that the faulty instruction given below which was inside the Timer 2 ISR :

   0x080015bc:  4877    wH   LDR   r0,[pc,#476] ; [0x800179c] = 0x20000130

This is done in attempt to increment a global counter uint16_t uiTimeCounter = 0;

It appears that the memory address got corrupted. Any insights on how should I proceed to solve this would really be helpful. Thank you.

This topic has been closed for replies.

2 replies

TDK
Super User
July 15, 2021

I would guess it is a stack overflow or an out of bounds array access.

>   0x080015bc:  4877    wH   LDR   r0,[pc,#476] ; [0x800179c] = 0x20000130

I don't see anything wrong with this. Perhaps I'm missing it.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TBhil.1
TBhil.1Author
Associate II
July 17, 2021

Please note that the actual address of the variable is 0x20000130, but the controller tries to access 0x28000130 as pointed by the BFAR register causing hard fault as 0x28000130 is out of the valid range of RAM addresses.  It appears that an extra bit is getting set. Also this fault does not occur every single time. In one board, the fault occurs within 15 mins after power on. While in another board, the fault occurs after more than 1 hour.

TDK
Super User
July 19, 2021

Double check for valid clock settings, voltage and wait states.

"If you feel a post has answered your question, please click ""Accept as Solution""."