完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我正在寻找一个bug,我怀疑XC8和我在一起。这个程序是一个引导加载程序,一旦我开始擦除闪存,更多的东西就开始崩溃。首先,Micro是PIC18F66 K80系列。这个问题一旦出现,下面的代码首先被执行。程序的基本描述是通过CANBUS接收消息,试图根据定义的格式将它们解析成一个命令,并处理这些命令,包括程序存储器的擦除/写入/验证。简化:当Prttf语句执行时,我可以使用调试器检查TBLPTR的值。当然,它指向“Bootloader仍然有效”的有效载荷的内存位置。然而,在执行第一存储器擦除块之后,下一个PRTTF写入垃圾。用调试器再次检查,TBLPTR仍然指向刚才擦除的内存。为什么编译器不保证它再次被正确地设置?
以上来自于百度翻译 以下为原文 I'm hunting down a bug where I'm having suspicions against XC8 messing with me. The program in question is a bootloader, and once I start erasing flash memory, more things start to break down. First, the micro is a PIC18F66K80 series. The problem exhibits once the code below is first executed. else if (blpLastLine.cmdType == BLP_EraseFlash) { response.dataLen = 0; response.isAck = true; // setup TABLPTR TBLPTRU = blpLastLine.address[2]; TBLPTRH = blpLastLine.address[1]; TBLPTRL = blpLastLine.address[0]; // erase block EECON1bits.EEPGD = 1; // point to Flash program memory EECON1bits.CFGS = 0; // access Flash program memory EECON1bits.WREN = 1; EECON1bits.FREE = 1; EECON2 = 0x55; EECON2 = 0xAA; EECON1bits.WR = 1; // erase block EECON1bits.FREE = 0; EECON1bits.WREN = 0; EECON1bits.EEPGD = 0; } Basic description of the program is it receives messages over canbus, tries to parse them into a command according to a format I defined and handles those commands, which include erase/write/verify of program memory. Simplified: while (true) { CanBuffer* b = canReceive(); if (b != NULL) handleMsg(b); printf("bootloader still activen"); } When the printf statement executes, I can inspect the value of TBLPTR using the debugger. Of course, it points to the memory location of the "bootloader still active" payload. However, after executing the first memory erase block, the next printf writes garbage. Inspecting again with the debugger, the TBLPTR still points to the memory we just erased. Why doesn't the compiler ensure it gets set properly again? |
|
相关推荐
1个回答
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
485 浏览 0 评论
5806 浏览 9 评论
2346 浏览 8 评论
2234 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3540 浏览 3 评论
1145浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1114浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
883浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
488浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 08:00 , Processed in 0.624225 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2233