1. Unlock FLASH_OPTCR and set PG_OTP bit in the FLASH_OPTCR register.
其中,解锁FLASH_OPTCR可以通过调用库函数HAL_FLASH_OB_Unlock(void)来完成。
2. Check the protection status of the target OTP word (see Table 17). The corresponding LOCKBi bit must be cleared to 0.
3. Write two OTP words (32 bits) corresponding to the 4-byte aligned address . Alternatively, the application software
can program separately the 16-bit MSB or 16-bit LSB. In this case the first 16-bit write operation starts immediately
without waiting for the second one.
4. Check that QW1 bit in FLASH_SR1 has been raised and wait until it is reset to 0.