2020-10-08 10:28 PM
FLASH->ACR |= FLASH_ACR_PRFTBE;
/* Flash 2 wait state */
FLASH->ACR &= (uint32_t)((uint32_t)~FLASH_ACR_LATENCY);
FLASH->ACR |= (uint32_t)FLASH_ACR_LATENCY_2;
2020-10-09 06:46 AM
When increasing clock speed, increase flash latency prior to the clock change to avoid an invalid intermediate state. Also do it in a single operation to avoid an invalid intermediate state.