[技术问答] FLASH模拟EEPOM 读写不对!问题何在,请高人指点!

[复制链接]
 楼主| hnxingzhe 发表于 2020-8-3 10:19 | 显示全部楼层 |阅读模式
int32_t main(void)
{
               
                uint8_t           temp,i;
                uint32_t          u32Addr  = 0x3fd0;
                uint8_t           u8Data   = 0xaa;
                uint16_t          u16Data  = 0xaa55;

               
                //M0P_CLOCK->PERI_CLKEN_f.GPIO = 1;
                M0P_CLOCK->PERI_CLKEN = 0x10100000;
                setup();
                M0P_GPIO->P0RIE_f.P03=1;

                for(i=5;i>0;i--)
                {
                                M0P_GPIO->P0OUT=0xff;
                                delay1ms(1000);

                                M0P_GPIO->P0OUT=0x00;
                                delay1ms(1000);
                }
                Flash_Init(FlashInt, 0);   
                Flash_SectorErase(u32Addr);
                Flash_WriteByte(u32Addr, u8Data);
                //temp=*((volatile uint8_t*)u32Addr);
                if(*((volatile uint8_t*)u32Addr) == u8Data)
                {
                        for(i=15;i>0;i--)
                        {
                                        M0P_GPIO->P0OUT=0xff;
                                        delay1ms(100);
                               
                                        M0P_GPIO->P0OUT=0x00;                               
                                        delay1ms(1000);
                        }               
                }       
                else
                {
                        for(i=3;i>0;i--)
                        {
                                M0P_GPIO->P0OUT=0xff;
                                delay1ms(500);

                                M0P_GPIO->P0OUT=0x00;
                                delay1ms(500);
                        }
                }
                while(1);
}
smartpower 发表于 2020-8-3 11:31 | 显示全部楼层
有官方库。
sgrtf661 发表于 2020-8-4 14:55 | 显示全部楼层
代理技术支持  qq:409946461
martinhu 发表于 2020-8-6 10:26 | 显示全部楼层
M0P_CLOCK->PERI_CLKEN = 0x10100000;
这个时钟使能,最好按比特控制来写
M0P_CLOCK->PERI_CLKEN_f.GPIO = 1;
M0P_CLOCK->PERI_CLKEN_f.RTC = 1;等等,
因为你这样一体写的时候,把bit31清零了,而bit31是flash的使能位……
另外,擦写flash的时候,不能有中断打扰
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

8

帖子

0

粉丝
快速回复 返回顶部 返回列表