完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
最近我用PIC16F18325处理器开始了一个项目。我需要利用PIC的EEPROM来写入和读取值,并且我使用代码配置器V3来生成代码。我使用MPLAB X IDE V4.05.项目只需要在EEPROM中写入四个字节,然后再读取这些值,并写入新的值以再次读取,等等。读取的值是不可靠的。试图跟踪调试器上返回的值显示值有时被正确保存,但大部分时间都有故障(随机值返回),似乎某些单元没有能力保留信息,有些则具有某种能力,等等,似乎是F的情况。ROM测试从单元0开始,在整个EEPROM中工作。我使用CurdDATAEEXRead字节(地址,value)将数据写入EEPROME和命令行= DATAEEA Read Byter(地址)来读取数据。这些函数似乎经过了精确的程序DESC。在处理器的数据表中嵌入用于处理EEPROM,但是保存是不可靠的。正如我所说的,保存数据和读取它似乎没有任何一致性或可靠性。问题源在EEPROM中确实被隔离,因为临时切换到使用常规存储器VA。保存价值的RS解决了项目的故障。我很感激任何关于我可能错过的建议,这个项目是非常紧急的。我将提供您需要的任何进一步的信息。
以上来自于百度翻译 以下为原文 I have recently started a project using the PIC16F18325 processor. I needed to utilize the PIC's EEPROM to write to and read values from and I made use of the code configurator v3 to generate the code. I am using MPLAB X IDE v4.05. The project requires only writing four bytes into the EEPROM, and subsequently reading those values back, and writing new values to be read again, and so on. The values read back are unreliable. Trying to trace the values returned on the debugger reveals the values are sometimes saved correctly but most of the time there was a failure (random values returned) It seems to be that certain cells have no ability to retain information, some have some ability and so on, as seems to be the case from testing by beginning from cell 0 and working my way up the entire EEPROM. I am using the command DATAEE_WriteByte( address, value ) To write the data to the EEPROM And the command val = DATAEE_ReadByte( address ) To read back the data. These functions seem to be going through the exact procedures described in the processor's datasheet for handling EEPROM, yet saving is unreliable. As I said, there does not seem to be any consistency or reliability with saving data and reading it back. Problem source has definitely been isolated at the EEPROM, since switching temporarily to using regular memory vars to save the values solves the project's malfunctions. I would appreciate any advice regarding anything I might have missed, this project is quite urgent. I will provide any further information you may need. |
|
相关推荐
6个回答
|
|
您的代码在启动后是否尝试写入EEPROM?你的电源延迟激活了吗?是否启用了棕色输出复位功能?如果你开始写作,而权力仍然稳定,你会得到坏的结果。
以上来自于百度翻译 以下为原文 Is your code attempting to write to EEPROM as soon as it starts? Do you have the power up delay activated? Do you have Brown Out reset enabled? If you start writing while the power is still stabilising, you will get bad results. |
|
|
|
你的函数等待写标志完成吗?芯片是否在规定的电压范围内运行?有合适的帽子吗?一个稳定的电源?
以上来自于百度翻译 以下为原文 Do you functions wait for the write flag to finish? Is the chip running within the specified voltage? With the proper caps? And a stable power supply? |
|
|
|
如果这些函数不起作用,唯一的选择是访问硬件寄存器并自己滚动。检查数据表。第11.3至11.4节
以上来自于百度翻译 以下为原文 If those functions do not work, the only option is to access the hardware registers and roll your own. Check the datasheet. Section 11.3 - 11.4 |
|
|
|
谢谢大家的回复。我已经编写了一些测试代码来测试控制器EEPROM最基本的功能:写一个值到EEPROM的第一个地址,然后读取它。它试图遵循产品数据表中规定的指导方针。这里是代码:(所有的NOP()不改变任何东西,我得到相同的结果有或没有它们)。当我在调试器中运行这个代码时,读回的值,即NVMDTAL的值,似乎总是255=0xFF,不管我写什么给EEPROM。我将任意值放入NVMDTL中,看看它们是否因为读取操作而改变,并且值总是变为255。控制器是PIC16F18326。有人会指出我在写EEPROM的过程中漏掉的东西,然后读取它的值吗?有初始化程序吗?
以上来自于百度翻译 以下为原文 Thanks all for your replies. I have written some test code to test the most basic functionality of the controller EEPROM: write a value to the first address of the EEPROM and read it back. It tries to follow the guidelines as specified in the product datasheet. Here is the code: char dataval = 0; void main(void) { // initialize the device SYSTEM_Initialize(); _delay( 1000 ); NVMCON1bits.NVMREGS = 1; // Configuarion Select bit, 1 = Access EEPROM NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMDATL = 0x02; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMADRH = 0x70; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMADRL = 0x00; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.RD = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); dataval = NVMDATL; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.WREN = 1; // Program/Erase enable bit, 1 = Allows program/erase cycle NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMDATL = 0x78; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); // Unlock routine: INTCONbits.GIE = 0; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON2 = 0x55; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON2 = 0xAA; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.WR = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); INTCONbits.GIE = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); while ( NVMCON1bits.WR ) ; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMDATL = 0x02; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.RD = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); dataval = NVMDATL; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); dataval = 0x87; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.WREN = 1; // Program/Erase enable bit, 1 = Allows program/erase cycle NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMDATL = 0x3C; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); INTCONbits.GIE = 0; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON2 = 0x55; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON2 = 0xAA; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.WR = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); INTCONbits.GIE = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); while ( NVMCON1bits.WR ) ; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMDATL = 0x1A; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); NVMCON1bits.RD = 1; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); dataval = NVMDATL; NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP(); while (1) { } } /** End of File */ (All the NOP()'s do not change anything, I got the same results with or without them). When I run this code in the debugger, the value read back, which is the value of NVMDATL, seems to always be 255 = 0xFF, no matter what I write to EEPROM. I'm putting arbitrary values into NVMDATL to see if they change as a result of a read operation, and the values always change to 255. The controller is PIC16F18326. Can someone point to something I missed in the procedure to write to EEPROM and read the value back? Is there an initialization procedure? |
|
|
|
解锁序列中不能有NOP,写入NVM将无法与它们一起工作。如果EEPROM代码保护开启,则无法读取/写入EEPROM。检查一下。我不能,因为你没有张贴配置。检查程序清单或程序内存(代码模式)的解锁序列,并确保编译器没有做什么有趣的。不太可能,但我想是可能的。
以上来自于百度翻译 以下为原文 The unlock sequence can't have NOPs in it and writes to NVM will not work with them. You can't read/write EEPROM if EEPROM code protection is on. Check that. I can't since you haven't posted the configuration. Check the assembly listing or program memory (code mode) for the unlock sequence and ensure the compiler isn't doing something funny there. Not likely but possible I suppose. |
|
|
|
非常感谢你的回复,结果是硬件问题。我们所拥有的整个系列控制器(和我们订购的类似的测试设备)显然有故障的EEPROM。未能正常写入和读取EEPROM的代码,成功地使用了我们拥有的不同控制器家族。不是完全兼容PIN,但对我们的项目来说是足够好的。然而,有价值的信息在那里。谢谢。
以上来自于百度翻译 以下为原文 mbrowning Thanks very much for the reply, it turns out it was a hardware issue. The entire series of controllers we had (and similar ones we ordered for testing) apparently had malfunctioning EEPROMs. The code which failed to write to and read from EEPROM properly, succeeded with a different family of controllers we had. Not entirely pin compatible, but good enough for our project. Nevertheless, valuable information there. Thanks. |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
729浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
628浏览 0评论
526浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 14:31 , Processed in 1.263876 second(s), Total 88, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号