问题
I'm trying to set dual bank mode for STM32F779II, but it doesn't set at all.
So I tried in the main before doing anything the following code
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
FLASH->OPTCR |= FLASH_OPTCR_nDBANK_Msk;
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
And When I tried to check if the memory is in Single or Dual Mode:
if((OBInit.USERConfig & OB_NDBANK_SINGLE_BANK) == OB_NDBANK_DUAL_BANK){
printf("Dual bank mode is set");
}
but that statement is never set true.
回答1:
The process is described in the reference manual.
To modify the user option value, follow the sequence below:
- Check that no Flash memory operation is ongoing by checking the BSY bit in the FLASH_SR register
- Write the desired option value in the FLASH_OPTCR register.
- Set the option start bit (OPTSTRT) in the FLASH_OPTCR register
- Wait for the BSY bit to be cleared.
You have implemented Step 2 only.
Note that to set dual bank mode, you have to clear that bit.
Bit 29 nDBANK: Not dual bank mode
1: The Flash user area is seen as a single bank with 256 bits read access.
0: The Flash user area is seen as a dual bank with 128 bits read access (dual bank mode feature active)
来源:https://stackoverflow.com/questions/57757204/setting-dual-bank-mode-on-stm32f779ii