完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
早上好,我有一个不寻常的问题在这里。我使用标准代码配置器创建EEPROM读/写功能。如果我调用DATAEEXRealEngEnter我的MIN()来测试它,它工作得很好。它在我的函数中挂起了一个系统,保存了一个数据块。我相信这是下面所有相关的代码。如果我取消了for循环中的Prtuf行,并注释掉DATAEEXRead字节,它运行并打印出预期的数据。编辑:配置文件副本被定义为4。我也知道我使用一个变量叫做“CRC”,但它实际上是一个校验和。将使它成为一个合法的CRC稍后,只是想看到现在工作这一点。和DATAEEA写字节:
以上来自于百度翻译 以下为原文 Good morning, I'm having an unusual problem here. I'm using the standard code configurator created EEPROM read/write functions. If I call DATAEE_WriteByte my main() just to test it out, it works fine. It's hanging the system in my function that saves a block of data, though. I believe this is all of the relevant code below. If I uncomment that printf line in the for-loop and comment out DATAEE_WriteByte, it runs through and prints out the expected data. EDIT: CONFIG_COPIES is defined as 4. I also know I use a variable called "crc" but it's really a checksum. Will be making it a legit crc later, just wanting to see this working for now though. struct sConfigBlock { uint16_t initialCal; uint16_t emptyCal; uint16_t previousADC; uint16_t manualCal; uint8_t curState; uint8_t sensorDirty; uint8_t crc; } configBlock; void configSave() { uint16_t i, j, base = 0; uint8_t crc = 0, *blockPtr = (uint8_t*)&configBlock; printf("Config savern"); configBlock.initialCal = emptyCal; configBlock.emptyCal = emptyCal; configBlock.manualCal = manualCal; configBlock.curState = curState; configBlock.sensorDirty = sensorDirty; configBlock.crc = 0; for (j=0; j } configBlock.crc = crc; for (i=0; i for (j=0; j DATAEE_WriteByte(base + j, blockPtr[j]); } } } And DATAEE_WriteByte: void DATAEE_WriteByte(uint16_t bAdd, uint8_t bData) { uint8_t GIEBitValue = INTCONbits.GIE; NVMADRH = ((bAdd >> 8) & 0xFF); NVMADRL = (bAdd & 0xFF); NVMDATL = bData; NVMCON1bits.NVMREGS = 0; NVMCON1bits.WREN = 1; INTCONbits.GIE = 0; // Disable interrupts NVMCON2 = 0x55; NVMCON2 = 0xAA; NVMCON1bits.WR = 1; // Wait for write to complete while (NVMCON1bits.WR) { } NVMCON1bits.WREN = 0; INTCONbits.GIE = GIEBitValue; // restore interrupt enable } |
|
相关推荐
4个回答
|
|
|
更新:我发现如果我写一个字节,它就不会挂上PIC。如果我再试一次,它就会挂断。
以上来自于百度翻译 以下为原文 UPDATE: I found it only won't hang the PIC if I write one byte. If I try any more than that, it hangs. |
|
|
|
|
|
也许为DATAEEAWRIGETEBY()函数发布代码?
以上来自于百度翻译 以下为原文 Maybe post the code for the DATAEE_WriteByte() function? |
|
|
|
|
|
我把它添加到OP。这正是MCC生成的。
以上来自于百度翻译 以下为原文 I added it to the OP. It's just what MCC generated. |
|
|
|
|
|
哦,它看起来好像它设定NVMGRs=0当它应该是1。我也应该使用0xF000的偏移量来进行EEPROM访问。我认为我实际上是覆盖程序Flash,破坏代码。因此,绞刑。
以上来自于百度翻译 以下为原文 Oh it looks like it set NVMREGS = 0 when it should be 1. I also should have been using an offset of 0xF000 for EEPROM access. I think I was actually overwriting program flash, corrupting the code. Thus the hang. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 04:47 , Processed in 0.880722 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2219