完善资料让更多小伙伴认识你,还能领取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 |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2662 浏览 1 评论
3220 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1792 浏览 1 评论
3621 浏览 6 评论
6001 浏览 21 评论
948浏览 4评论
1320浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
594浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1313浏览 3评论
1371浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-1 14:09 , Processed in 1.067058 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号