Hi!
Can someone explain to me why this code:
Display All
kills STM32G070KB device, when was written with J-Flash, but works great with STM32G071CB with the same Errata note for RDP protection.
Same code works great for both MCUs when were written with Segger Embedded Studio.
Thank you!
Can someone explain to me why this code:
C Source Code
- // Is FLASH_CR register locked for writing?
- if (FLASH->CR & FLASH_CR_LOCK)
- {
- // Unlocking FLASH_CR register
- FLASH->KEYR = KEY1;
- FLASH->KEYR = KEY2;
- }
- // Unlocking FLASH option register
- if (FLASH->CR & FLASH_CR_OPTLOCK)
- {
- FLASH->OPTKEYR = OPTKEY1;
- FLASH->OPTKEYR = OPTKEY2;
- }
- // Setting RDP level to 1
- FLASH->OPTR &= ~FLASH_OPTR_RDP;
- FLASH->OPTR |= 0xBB; // Any value except 0xAA and 0xCC
- while (FLASH->SR & FLASH_SR_BSY1);
- FLASH->CR |= FLASH_CR_OPTSTRT;
- while (FLASH->SR & FLASH_SR_BSY1);
- // Updating option bytes by resetting of the device
- FLASH->CR |= FLASH_CR_OBL_LAUNCH;
Same code works great for both MCUs when were written with Segger Embedded Studio.
Thank you!