在 STM32f779ii 上设置双组模式

Setting dual bank mode on STM32f779ii

我正在尝试为 STM32F779II 设置双组模式,但根本没有设置。

所以我在执行以下代码之前主要尝试了以下代码

  HAL_FLASH_Unlock();

  HAL_FLASH_OB_Unlock();

  FLASH->OPTCR |= FLASH_OPTCR_nDBANK_Msk;

  HAL_FLASH_OB_Lock();

  HAL_FLASH_Lock();

当我试图检查内存是单模式还是双模式时:

if((OBInit.USERConfig & OB_NDBANK_SINGLE_BANK) == OB_NDBANK_DUAL_BANK){
     printf("Dual bank mode is set");
    }

但该声明永远不会成立。

参考手册中描述了该过程。

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.

您只执行了第 2 步。

请注意,要设置双银行模式,您必须清除那个位。

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)