2021-10-11 06:46 AM
In the datasheet (RM0444) for 512k dual bank devices, it looks like the last page of bank 1 is 127 and the first page of bank 2 is 256 (see section 3.3.1)
The flash control register (see 3.7.5) says, the valid values for PNB is from 0 (page 0) to 0x17F (page 383).
In the STM32G0 HAL FLASH example for Nucleo G01BRE, however, the C procedure to calculate the page from a given address calculates page 0 for the first bank 2 address (0x0804'0000).
static uint32_t GetPage(uint32_t Addr)
{
uint32_t page = 0;
if (Addr < (FLASH_BASE + FLASH_BANK_SIZE))
{
/* Bank 1 */
page = (Addr - FLASH_BASE) / FLASH_PAGE_SIZE;
}
else
{
/* Bank 2 */
page = (Addr - (FLASH_BASE + FLASH_BANK_SIZE)) / FLASH_PAGE_SIZE;
}
return page;
}
Used STM32 Cube G0 package version: 1.5.0
Which one is correct?
Solved! Go to Solution.
2021-10-11 09:06 AM
2021-10-11 09:06 AM
2021-10-12 02:23 AM
Hello @Markus8494 and welcome to the Community :)
Thank you for rising this up.
The RM is incorrect and pending correction.
I've just checked the status of this request and asked the appropriate owner to correct this error in the coming release of the RM.
Thanks for your contribution.
Imen
2021-10-12 03:34 AM
Hello,
thank you both for your quick and clarifying response.