STM8 内部flash

STM8 内部flash_第1张图片

举例

typedef enum {
    FLASH_MEMTYPE_PROG      = (u8)0x00, /*!< Program memory */
    FLASH_MEMTYPE_DATA      = (u8)0x01 /*!< Data EEPROM memory */
} FLASH_MemType_TypeDef;

int main()
{
    u32 addr = 0x4000;

    CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);

    while(1)
    {
        FLASH_Unlock(FLASH_MEMTYPE_DATA); //根据MemType填写

        FLASH_EraseByte(addr);

        FLASH_ProgramByte(addr, 0xa5);

        if(FLASH_ReadByte(addr) == 0xa5)
        {
            ;
        }

        FLASH_Lock(FLASH_MEMTYPE_DATA);

        delay_ms(500);
    }
}

你可能感兴趣的:(STM8)