cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable SRAM parity bit without using STM32CubeProgrammer

ABals.2
Associate II

I am trying to enable the SRAM parity check, code snippet is as follows:

FLASH_OBProgramInitTypeDef config;
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
HAL_FLASHEx_OBErase();
HAL_FLASHEx_OBGetConfig(&config);
config.USERConfig = 0x00;
HAL_FLASHEx_OBProgram(&config);
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();

The code gets stuck at HAL_FLASH_OB_Launch(); and the IAR IDE hangs and exits out of debug mode.

3 REPLIES 3
Jaroslav JANOS
ST Employee

Hello @ABals.2,

as described in the reference manual, the OBL Launch causes a system reset. This is a standard behavior.

BR,
Jaroslav

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.

ABals.2
Associate II

I understand the system reset is a standard behavior, what I want to know is that How to enable SRAM parity bit via code, as follows: On system startup I will check if the SRAM parity is enabled or disabled, if enabled no action needed, if disabled, I need to enable it, so for enabling the pin I need to program it and call the OBL launch, which will do the system reset, but can you provide me with a solution that how can I achieve the enabling of SRAM parity bit and then proceed with my application code.

Hello @ABals.2,

you just described the solution - on startup, you check the SRAM parity bit, and if not enabled, you enable it. This OBL launch will cause a reset, so the SRAM parity bit will be checked again. Now it will be enabled for sure (otherwise there is an issue with FLASH programming) and the execution will proceed with your application code.

BR,
Jaroslav

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.