AnsweredAssumed Answered

Hard fault problem

Question asked by rouse.alan.001 on Jun 10, 2014
Latest reply on Jun 11, 2014 by rouse.alan.001
For several years I have developed software for an STM32F103 target using Eclipse/OpenOCD/Olimex ARM-USB-OCD.  Recently my hard drive failed so I replaced it and re-installed everything.  My project will not now run, and I have located the problem as follows:

After a reset the code ensured the RCC is set to the internal 8MHz RC clock:
0x08001e26: InitRCC+46             ldr r3, [pc, #560]
0x08001e28: InitRCC+48             ldr r2, [r3, #0]
0x08001e2a: InitRCC+50             ldr r3, [r2, #4]
0x08001e2c: InitRCC+52             bfc r3, #0, #2
0x08001e30: InitRCC+56             str r3, [r2, #4]

At line 2, r2 is loaded with 0x40021000 (RCC clock). At line 3, r3 is loaded from address 0x40021004.  The code then proceeds to enable the prefetch buffer in preparation for setting flash latency then selecting a crystal clock:
0x0800088c: InitFlash+8            ldr r3, [pc, #84]
0x0800088e: InitFlash+10           ldr r3, [r3, #0]
0x08000890: InitFlash+12           ldrb r2, [r3, #0]
0x08000892: InitFlash+14           orr.w r2, r2, #16
0x08000896: InitFlash+18           strb r2, [r3, #0]

At line 2, r3 is loaded with 0x40022000. At line 3 r2 should be loaded with the contents of 0x40022000 (ACR).  Instead the processor vectors to the hard fault exception.

This suggests that register 0x40022000 is not used, yet it is, and register 0x40021004 works correctly.  Can anyone explain why?

The problem is particularly frustrating since all works correctly before my hard drive failed.  The code has not changed, and as far as I am aware all applications and drivers are the same.