2024-01-11 11:30 PM
Hello,
I'm new in ARM programming, I'm trying to study how CHIP work using the documentation.
I wanna unlock the flash memory and according with documentation:
1. Write KEY1 = 0x4567 0123 in the FLASH key register (FLASH_KEYR)
2. Write KEY2 = 0xCDEF 89AB in the FLASH key register (FLASH_KEYR).
Any wrong sequence locks the FLASH_CR registers until the next system reset. In the case
of a wrong key sequence, a bus error is detected and a Hard Fault interrupt is generated.
I write this simple code:
2024-01-12 12:20 AM
Hello @dmrsim
In case of an unsuccessful unlock operation, this Lock bit in FLASH_CR remains set until the next system reset. You may need to read this bit before authorizing the access and after that you can wait to check if flash unlock is complete.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-12 12:35 AM
Hello,
thanks for your reply.
Before unlock I have tried also in debug mode, to read flash->CR bit, but also this read cause HardFault(I cannot read Flash registers using my code)....
Could you help me?
2024-01-12 01:27 AM
Really sorry, my big mistake...I forgot to init: FLASH_TypeDef *flash = FLASH;
2024-01-12 01:33 AM
Hi @dmrsim
You may check the faults view to see why it is triggered. We don't have all the inputs needed to help further. You can check clocks in RCC register view, or you can simply see the implementation of our HAL driver.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.