完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
你好,
我正在使用SPC570S-DISP发现套件和SPC5Studio v5.6,我正在尝试使用EEPROM模拟以便为我的应用程序保存一些数据。 我没有使用从ST网站下载的闪存驱动程序,因此我正在尝试按照RM0349参考手册中的指示编写自己的代码。 我尝试做的是: 1)仅擦除高内存中的4个8KB扇区(用于数据存储器) 2)在数据存储器的开头写入0xAA55AA55(0x00800000) 擦除操作似乎成功完成(在操作之后,MCR寄存器中的PEG位等于1),但写操作不起作用(PEG = 0)。 这是我的代码: #define FLASH_TEST_ADDR_0(uint32_t *)(0x00800000UL) uint32_t temp; uint32_t status_erase; uint32_t status_write; uint32_t *地址; //擦除 FLASH_0.LOCK1.R = 0xFFFFFFF0; //解锁用于EEPROM仿真的4个8KB高存储器扇区 FLASH_0.MCR.R = 0x00000004; //激活ERASE位 FLASH_0.SEL0.R = 0x00000000; FLASH_0.SEL1.R = 0x0000000F; //仅选择4个8KB高内存扇区进行擦除 FLASH_0.SEL2.R = 0x00000000; FLASH_0.MCR.R = 0x00000005; //激活高压位以便开始擦除 做{ temp = FLASH_0.MCR.R; } while(!(temp& 0x00000400)); //等待操作完成 status_erase = FLASH_0.MCR.R& 0x00000200; //检查操作结果并将其存储在status_erase变量中 FLASH_0.MCR.R = 0x00000004; //高电压位已禁用 FLASH_0.MCR.R = 0x00000000; // ERASE位已停用 //此时status_erase值等于0x00000200,表示操作已成功完成 //写 address = FLASH_TEST_ADDR_0; //将地址指针初始化为模拟EEPROM的第一个地址 FLASH_0.MCR.R = 0x00000010; //激活PGM位 *地址= 0xAA55AA55; //设置要写入的数据值 FLASH_0.MCR.R = 0x00000011; //激活高压位以开始编程 做{ temp = FLASH_0.MCR.R; } while(!(temp& 0x00000400)); //等待操作完成 status_write = FLASH_0.MCR.R& 0x00000200; //检查操作结果并将其存储在status_write变量中 FLASH_0.MCR.R = 0x00000010; //高电压位已禁用 FLASH_0.MCR.R = 0x00000000; // PGM位已禁用 //此时status_write值等于0x00000000,表示操作出错 你能帮我找一下怎么回事?可能这是一个愚蠢的问题,因为我对这个微控制器缺乏经验,我刚才正在探索。 提前致谢, 亲切的问候。 丹尼尔 以上来自于谷歌翻译 以下为原文 Hello, I'm working with SPC570S-DISP discovery kit and SPC5Studio v5.6, and I'm trying to use EEPROM emulation in order to save some data for my application. I'm not using the flash drivers downloadable from ST site, so I'm trying to write my own code following the indications in RM0349 reference manual. What I try to do is: 1) erase only the 4 8KB sectors placed in high memory (used for data memory) 2) write 0xAA55AA55 at the start of data memory (0x00800000) The erase operation seems to be completed successfully (after operation, PEG bit in MCR register equals to 1), but write operation doesn't work (PEG = 0). Here is my code: #define FLASH_TEST_ADDR_0 ( uint32_t *) (0x00800000UL) uint32_t temp; uint32_t status_erase; uint32_t status_write; uint32_t *address; // erase FLASH_0.LOCK1.R = 0xFFFFFFF0; //unlock 4 8KB high memory sectors used for EEPROM emulation FLASH_0.MCR.R = 0x00000004; //activate ERASE bit FLASH_0.SEL0.R = 0x00000000; FLASH_0.SEL1.R = 0x0000000F; //select only 4 8KB high memory sectors for erasing FLASH_0.SEL2.R = 0x00000000; FLASH_0.MCR.R = 0x00000005; //activate High Voltage bit in order to start erasing do { temp = FLASH_0.MCR.R; } while ( !(temp & 0x00000400) ); //wait for operation to be completed status_erase = FLASH_0.MCR.R & 0x00000200; //check for operation result and store it in status_erase variable FLASH_0.MCR.R = 0x00000004; //High Voltage bit deactivated FLASH_0.MCR.R = 0x00000000; //ERASE bit deactivated //status_erase value at this point equals to 0x00000200, that means that the operation has been succesfully completed //write address = FLASH_TEST_ADDR_0; //initialize address pointer to first address of emulated EEPROM FLASH_0.MCR.R = 0x00000010; //activate PGM bit *address = 0xAA55AA55; //set the data value to be written FLASH_0.MCR.R = 0x00000011; //activate High Voltage bit in order to start programming do { temp = FLASH_0.MCR.R; } while ( !(temp & 0x00000400) ); //wait for operation to be completed status_write = FLASH_0.MCR.R & 0x00000200; //check for operation result and store it in status_write variable FLASH_0.MCR.R = 0x00000010; //High Voltage bit deactivated FLASH_0.MCR.R = 0x00000000; //PGM bit deactivated //status_write value at this point equals to 0x00000000, that means that the operation went wrong Could you please help me to find what is wrong? Probably it's a stupid issue due to my inexperience about this microcontroller that I'm exploring just now. Thanks in advance, kind regards. Daniel |
|
相关推荐
2个回答
|
|
|
丹尼尔你好,
您是否尝试过来自SPC5Studio Marketplace的EEPROM仿真软件? Application repository示例中有一些示例。 最好的祝福 二万 以上来自于谷歌翻译 以下为原文 Hello Daniel , Did you try EEPROM Emulation Software coming from SPC5Studio Marketplace ? There are some examples in Application repository example. Best regards Erwan |
|
|
|
|
|
你好,Erwan,
我离开了一段时间,现在发现你的回复了。 谢谢你的建议,听起来非常好!实际上我没有考虑在市场上检查额外的司机,这似乎是我正在寻找的。 非常感谢你的帮助。 亲切的问候, 丹尼尔 以上来自于谷歌翻译 以下为原文 Hello Erwan, I was out of office for a while and found now your reply. Thanks for your suggestion, sounds very good! Actually I didn't consider to check in market place for additional drivers, this seems to be what I was looking for. Thanks a lot for your help. With kind regards, Daniel |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
663浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 08:01 , Processed in 0.812575 second(s), Total 73, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2324