Setting dual bank mode on STM32f779ii

有些话、适合烂在心里 提交于 2020-01-25 08:05:27

问题


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:

  1. Check that no Flash memory operation is ongoing by checking the BSY bit in the FLASH_SR register
  2. Write the desired option value in the FLASH_OPTCR register.
  3. Set the option start bit (OPTSTRT) in the FLASH_OPTCR register
  4. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!