完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我用的是STM8L152R8 ..
我测试闪存编程......但是,现在存在一些问题...... #pragma location ='FLASH_CODE' void Mem_ProgramBlock(u16 BlockNum,const u8 * Buffer) { u16计数= 0; u32 StartAddress = 0; / *设置起始地址,指的是mem_type * / StartAddress = FLASH_PROGRAM_START_PHYSICAL_ADDRESS; / *指向第一个块地址* / StartAddress = StartAddress +((u32)BlockNum * FLASH_BLOCK_SIZE); / *标准编程模式* / FLASH-&gt; CR2 | =(u8)0x01; / *将数据字节从RAM复制到FLASH存储器* / for(Count = 0; Count&lt; FLASH_BLOCK_SIZE; Count ++) { }} 我使用内存....我在此函数之前解锁cpu ....如下所示 FLASH-> CR1 = 0; //标准编程时间(EEPM,WAITM,IE Clear) FLASH-&gt; PUKR = FLASH_RASS_KEY1; //解锁Flash数据 FLASH-&gt; PUKR = FLASH_RASS_KEY2; while((FLASH-> IAPSR&amp; FLASH_IAPSR_PUL)== 0);我没有发现一些bug ...... 始终CPU在闪存编程功能中停止... 请帮帮我.. 以上来自于谷歌翻译 以下为原文 I use STM8L152R8.. I test flash programming... But, now some problem exists... #pragma location = 'FLASH_CODE' void Mem_ProgramBlock(u16 BlockNum, const u8 *Buffer) { u16 Count = 0; u32 StartAddress = 0;/* Set Start address wich refers to mem_type */ StartAddress = FLASH_PROGRAM_START_PHYSICAL_ADDRESS; /* Point to the first block address */ StartAddress = StartAddress + ((u32)BlockNum * FLASH_BLOCK_SIZE);/* Standard programming mode */ FLASH->CR2 |= (u8)0x01; /* Copy data bytes from RAM to FLASH memory */ for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++) { }} I use memory.... I unlock cpu before this function.... as below FLASH->CR1 = 0; // Standard programming Time (EEPM, WAITM, IE Clear) FLASH->PUKR = FLASH_RASS_KEY1; // Unlock Flash Data FLASH->PUKR = FLASH_RASS_KEY2; while ((FLASH->IAPSR & FLASH_IAPSR_PUL) == 0); I did not find out some bug...... Always CPU halted in flash programming functioin... Please help me.. |
|
相关推荐
2个回答
|
|
|
编程时不能使用闪存。
在字节和字编程情况下,cpu将一直等到闪存准备就绪,当操作完成时,才能继续。 在块编程中,您仍需要在闪存仍处于忙碌状态时提供数据。 这意味着必须从RAM执行复制循环。 我建议你看看 http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8016.html 实施为参考。解压缩后,目录中有一个示例 以上来自于谷歌翻译 以下为原文 The Flash memory cannot be used when programming. In byte and word programming cases, the cpu will wait until the flash is ready again, when the operation is done, to continue. In block programming, you still need to feed data while the flash memory is still busy. This means the copy loop must be executed from RAM. I recommend you look at the http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8016.html implementation as reference. Once unzipped, there is an example in the directory |
|
|
|
|
|
这清楚地描述在
http://www.st.com/resource/en/programming_manual/cd00226555.pdf PM0054第5.2章 以上来自于谷歌翻译 以下为原文 This is clearly described in the http://www.st.com/resource/en/programming_manual/cd00226555.pdf PM0054 chapter 5.2 |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1476 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1531 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3678 浏览 1 评论
3871 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2485 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
759浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
691浏览 5评论
734浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
989浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
790浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-18 13:52 , Processed in 0.720186 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2091