完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我使用的是PIC18F26K40,使用的功能是EEPROMIX写(0x00,0x09);但是这个函数没有被识别。错误消息是:0:错误:(500)未定义的符号:{DeTe/Dea/DeultPIC18F26K40McPrdulaPrimeStas.Outux.Obj.BuyYyEEEP(DIST/Dea/DeultPIC18F26K40MCPPrdPrExtWS.Outual.Obj.)我已经尝试了XC8链接器运行时选项“链接”“Helar图书馆”,但没什么区别。我做错什么了?
以上来自于百度翻译 以下为原文 Hi, I am using a PIC18F26K40 and using the function eeprom_write(0x00, 0x09); However the function is not recognised. Same with eeprom_read(); The error message is :0: error: (500) undefined symbols: _Write_b_eep(dist/default/productionPIC18F26K40_MCPQuad_presetSWs.production.obj) _Busy_eep(dist/default/productionPIC18F26K40_MCPQuad_presetSWs.production.obj) I have tried the XC8 linker Runtime option "link in peripheral library", but it doesn't make any difference. What am I doing wrong? |
|
相关推荐
15个回答
|
|
|
XC8的最新版本与外围库无关,必须从下载的同一页单独下载它们。
以上来自于百度翻译 以下为原文 Recent versions of XC8 don't come with the peripheral libraries, you have to download them separately from the same page you downloaded the compiler. |
|
|
|
|
|
哦,事实上,外围图书馆支持是不可用的18F26K40。可以通过代码配置器来完成,或者…谢谢
以上来自于百度翻译 以下为原文 oh actually, peripheral library support is not available for the 18F26K40. Can it be done via the code configurator, or .... thanks |
|
|
|
|
|
最好的是,从数据表中抓取一些代码行并将它们放入您的源代码中(将那个小汇编程序转换成C代码非常简单)。
以上来自于百度翻译 以下为原文 Best off, is grabbing some lines of code from the datasheet and put them into your sources (converting that little assembler into C will be quite trivial) |
|
|
|
|
|
非常感谢。我将张贴代码用于单字节读写,以防有人需要。//EEPROM单字节读写例程用于PIC18F26K40CHAR ReADeEPROM(char地址){NVMCON1BIT.NVMGRe0=0;//设置EEPROM访问NVMCON1BIT.NVMGRIG1=0;/ /设置EEPROM访问NVMADRL =地址;/ /设置地址到从NVMCON1BITS.RD=1;//Read返回NVMADT;//读取数据在NVMADAT无效的写EEPROM(char地址,char data){nvMCON1BIT.NVMGRe0=0;//设置EEPROM访问NVMCON1BIT.NVMGRIG1=0;//设置EEPROM访问NVMADRL =地址;//地址写入NVMATAT =数据;//数据要写入NVMCON1比特。WEEN=1;//允许写入ItCONTITY。GIE=0;//禁用中断;不是一个好主意NVMCON2= 0x55;/ /解锁序列NVMCON2= 0xAA;/ /解锁序列NVMCON1BIT.WR=1;//开始写入(NVMCON1BIT.WR);/ /等待写入完成ItCONBITI. GEE=1;/ /允许中断NWMCON1BIT。WREEN=0;//禁用写}
以上来自于百度翻译 以下为原文 great thanks. I'll post the code for single byte reads and writes, in case someone wants it. //eeprom single byte read and write routines for PIC18F26K40 char readEEprom(char address) { NVMCON1bits.NVMREG0 = 0; //setup eeprom access NVMCON1bits.NVMREG1 = 0; //setup eeprom access NVMADRL = address; //set address to read from NVMCON1bits.RD = 1; // read return NVMDAT; //read data is in NVMDAT } void writeEEprom(char address, char data) { NVMCON1bits.NVMREG0 = 0; //setup eeprom access NVMCON1bits.NVMREG1 = 0; //setup eeprom access NVMADRL = address; //address to write to NVMDAT = data; // data to be written NVMCON1bits.WREN = 1; // enable writes INTCONbits.GIE = 0; //disable interrupt; not essential but a good idea NVMCON2 = 0x55; //unlock sequence NVMCON2 = 0xAA; //unlock sequence NVMCON1bits.WR = 1; //begin write while(NVMCON1bits.WR); // wait for write to complete INTCONbits.GIE = 1; //enable interrupts NVMCON1bits.WREN = 0; //disable writes } |
|
|
|
|
|
|
|
|
|
|
|
我建议在NVMeRG勘误表的这些功能的末尾将NVMRG返回闪存。
以上来自于百度翻译 以下为原文 I'd suggest returning NVMREG back to Flash memory at the end of those functions for the NVMREG errata. |
|
|
|
|
|
谢谢,但我不明白,虽然我想,你到底是什么意思。而且,这是否重要,因为我在链接器选项中包含了+nvMeReg勘误表吗?
以上来自于百度翻译 以下为原文 thanks, but I don't understand that, though I would like to, so what do you mean exactly. Also, would it matter anyway, being that I have included the +NVMREG Errata in the linker options? |
|
|
|
|
|
当我理解勘误表时,在链接启动选项中添加ErrATa= NVMRG将NVMRG位=B’10’指向程序快闪存储器,以确保在闪存中存储的常数和文字字符串的初始化将起作用。它不将NVMRG位设置在其他任何地方。因此,如果将NVMRG位更改为B’10’以外的任何内容,则应将其还原为B’10’;否则,访问闪存中存储的数据将失败。此外,如果ISR使用常量或文字字符串,则必须在更改NVMRG之前禁用中断,并将其恢复到B’10’之前。启用中断,或者ISR将无法访问常量或文字字符串。您的EEPROM功能不这样做。
以上来自于百度翻译 以下为原文 As I understand the errata, adding --ERRATA=NVMREG to the linker options sets the NVMREG bits = b'10' to point to the program flash memory before the C startup code is executed to ensure initialization of constants and literal strings, which are stored in flash memory, will work. It does not set the NVMREG bits anywhere else. So, if you change the NVMREG bits to anything other than b'10' you should restore it back to b'10'; otherwise, accessing data stored in the flash memory will fail. Also, if your ISR uses constants or literal strings then interrupts must be disabled before changing NVMREG and restored to b'10' before interrupts are enabled, or your ISR will fail to access the constants or literal strings. Your EEPROM functions are not doing that. |
|
|
|
|
|
我懂了。那么,以下是正确的吗?char ReaDEEPROM(char地址){char TEMP=0;//存储区域为数据GEE=0;//禁用中断NVMCON1BIT.NVMGRe0=0;//设置EEPROM访问NVMCON1BIT.NVMGRIG1=0;//设置EEPROM访问NVMADRL=地址;/SET地址从NVMCON1BITS RD=1读取;/ /从地址TEMP= NVMAT读取数据;//存储读取数据GEE=1;//启用中断NVMCON1BITS NVMGRIG0=0;//设置闪存访问NVMCON1BITS NVMGRIG1=1;//设置闪存访问返回温度;/返回读写PROM(CHAR地址,字符数据){GIE=0;//禁用中断NVMCON1比特。NVMGRe0=0;//设置EEPROM访问NVMCON1NVMGRIG1=0;//设置EEPROM访问NVMADRL =地址;//地址写入NVMADAT=数据;//数据要写入NVMCON1BIT。WREEN=1;//允许写ItCONTITES。GIE=0;/ /禁用中断;不是必需的,但好主意NVMCON2= 0x55;/ /解锁序列NVMCON2= 0xAA;/ /解锁序列NVM;CON1BITS。WR=1;//开始写入(NVMCON1BIT.WR);/ /等待写入完成ItCONBITI. GEE=1;//启用中断NVMCON1BITS=0;//禁用写入NVMCON1BITS NVMGRIG0=0;//设置Flash访问NVMCON1BITS NVMGRIG1=1;//设置Flash Access }
以上来自于百度翻译 以下为原文 I see. So, is the following correct then? char readEEprom(char address) { char temp =0; //storage area for data GIE = 0; //disable interrupts NVMCON1bits.NVMREG0 = 0; //setup eeprom access NVMCON1bits.NVMREG1 = 0; //setup eeprom access NVMADRL = address; //set address to read from NVMCON1bits.RD = 1; // read data from address temp = NVMDAT; //store read data GIE =1; //enable interrupts NVMCON1bits.NVMREG0 = 0; //setup flash access NVMCON1bits.NVMREG1 = 1; //setup flash access return temp; //return read data } void writeEEprom(char address, char data) { GIE = 0; //disable interrupts NVMCON1bits.NVMREG0 = 0; //setup eeprom access NVMCON1bits.NVMREG1 = 0; //setup eeprom access NVMADRL = address; //address to write to NVMDAT = data; // data to be written NVMCON1bits.WREN = 1; // enable writes INTCONbits.GIE = 0; //disable interrupt; not essential but a good idea NVMCON2 = 0x55; //unlock sequence NVMCON2 = 0xAA; //unlock sequence NVMCON1bits.WR = 1; //begin write while(NVMCON1bits.WR); // wait for write to complete INTCONbits.GIE = 1; //enable interrupts NVMCON1bits.WREN = 0; //disable writes NVMCON1bits.NVMREG0 = 0; //setup flash access NVMCON1bits.NVMREG1 = 1; //setup flash access } |
|
|
|
|
|
也许,虽然在我看来。在退出时保存和恢复到相同的状态会更正确。
以上来自于百度翻译 以下为原文 Probably, although in my opinion. saving and restoring them to the same state when you exit would be more correct. |
|
|
|
|
|
这将是一种更通用的方法,但是需要更多的代码空间来保存和恢复NVMRG。保存和恢复GIE也一样,如果这是应用程序所需要的。在我看来,保持NVMeRG默认为B’10可能更有效,因为访问闪存更频繁。
以上来自于百度翻译 以下为原文 That would be a more generic method, but it takes more code space to save and restore NVMREG. The same goes for saving and restoring GIE, if that is what the application required. In my opinion, keeping NVMREG default to b'10' is probably more efficient, since accessing flash memory is performed more often. |
|
|
|
|
|
即使在XC8中,普通字符类型是无符号字符,也应该使用无符号字符(或者更好地使用UINT8YT)。26K40中的EEPROM有1024字节,所以它的地址值大于字符大小;也就是说,地址应该是int大小,也需要写入NVMADRH。在启用中断之前还原NVMRG。如果您的代码默认NVMRG到B’10’,那么您的函数就不需要清除NVMGRI0。最后,我将中断最少的循环次数。
以上来自于百度翻译 以下为原文
|
|
|
|
|
|
|
|
|
|
|
|
char TEMP=0;//存储区域用于数据不需要初始化。
以上来自于百度翻译 以下为原文 char temp =0; //storage area for data Unnecessary to initialize. |
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
454 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3529 浏览 3 评论
1121浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
872浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
466浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 18:12 , Processed in 2.904458 second(s), Total 100, Slave 83 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4560