完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我是STM8编程的新手。我正在STM8S103F3P6微控制器上进行小项目,我需要在EEPROM存储器中保存一些(27字节)值,并在每次上电时重新加载它们。我看到ST stdLib的一个例子,并试图为我的项目改变它。这是我的问题。当我尝试用函数FLASH_ProgramByte()保存超过1个字节时,为exaple:
(......) FLASH_ProgramByte(0x4000,0x12); FLASH_ProgramByte(0x4001,0x34); FLASH_ProgramByte(0x4002,0x56); (......) 当我在调试会话中查看EEPROM内容时,一些变量被正确保存,但有些变量为0.此外,当我尝试在应用程序启动时重新加载这些值,即使设置了特定地址的EEPROM字节,函数FLASH_ReadByte(0x400x);经常返回0,有时只返回正确的值。 MCU从HSI运行在16MHz。我犯了什么错吗?当然,内存已解锁。 #stm8s103-EEPROM,闪存 以上来自于谷歌翻译 以下为原文 Hello, I'm pretty new in STM8 programming. I'm making small project on STM8S103F3P6 microcontroller and I need to save some (27 bytes) values in EEPROM memory and reload them at every power up. I saw an example from ST stdLib and tried to change it for my project. And here is my problem. When I try to save more than 1 byte with function FLASH_ProgramByte(), for exaple: (...) FLASH_ProgramByte(0x4000, 0x12); FLASH_ProgramByte(0x4001, 0x34); FLASH_ProgramByte(0x4002, 0x56); (...) when I view EEPROM content in debugging session, some variables are saved correctly, but some are 0. Also, when I try to reload these values on application start even if EEPROM byte at specific address is set, function FLASH_ReadByte(0x400x); often returns 0, only sometimes returns correct value. MCU is running at 16MHz from HSI. Do I make any mistake? Of course memory is unlocked. #stm8s103-eeprom-flash |
|
相关推荐
2个回答
|
|
16 Mhz仍然可以在没有等待状态的情况下工作,但它已达到极限。您是否尝试在EEPROM访问中将STM8配置为1等待状态(根据16 Mhz以上的操作要求)?如果是的话,它有帮助吗?
菲利普 以上来自于谷歌翻译 以下为原文 16 Mhz should still work without wait states, but it is at the limit. Have you tried configuring your STM8 for 1 wait state in EEPROM access (as required for operation above 16 Mhz)? If yes, did it help? Philipp |
|
|
|
好的,我忘记了EOP位,现在写入EEPROM工作正常。在调试会话期间的内存视图窗口中,每个EEPROM字节都是正确的但阅读仍然无效。我试图从内存中读取值(27个字节),我总是得到一些零,一些值在无效地址上,每个字节都是错误的。我的问题是,当我正在写入并暂停执行以获得正确的值时,我是否需要在读取EEPROM作为EOP时检查另一位?为什么下面的代码不起作用?
VAL1 = FLASH_ReadByte(0x4000的); VAL2 = FLASH_ReadByte(0x4001的); VAL3 = FLASH_ReadByte(0x4002); ....... 感谢帮助! 以上来自于谷歌翻译 以下为原文 OK, I forgot about EOP bit and now writing to EEPROM works fine. In memory view window during debugging session every EEPROM byte is correct. But reading is still invalid. I'm trying to read values (27 bytes) from memory and I always get some zeros, some values are on invalid address, every byte is wrong. My question is do I need to check another bit when reading EEPROM as EOP when I'm writing and pause execution to get proper values? Why code like below does not work? val1=FLASH_ReadByte(0x4000); val2=FLASH_ReadByte(0x4001); val3=FLASH_ReadByte(0x4002);....... Thanks for help! |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2730 浏览 1 评论
3239 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1808 浏览 1 评论
3647 浏览 6 评论
6035 浏览 21 评论
1339浏览 4评论
198浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
350浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
442浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
273浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 11:25 , Processed in 1.035998 second(s), Total 49, Slave 43 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号