完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
嗨,有没有人想知道如何在XC8上读取PIC16LF1836的IDOLC值?现在,我使用#pragma语句来设置4个字节(但是以后计划使用IPE为每个设备填充一个唯一的序列号):我希望能够在我的软件中读取这些值,但是到目前为止没有任何运气。非常感谢您的帮助,Alexander
以上来自于百度翻译 以下为原文 Hi, Does anybody have any ideas on how to read the IDLOC values on a PIC16LF18346 in XC8? For now I am using the #pragma statements to set the 4 bytes (but later plan to use IPE to fill these with a unique serial number for every device): #pragma config IDLOC0 = 0x00 #pragma config IDLOC1 = 0x01 #pragma config IDLOC2 = 0x02 #pragma config IDLOC3 = 0x03 I would like to be able to read these values within my software, but so far without any luck. uint8_t getiDLoc0(void) { const uint8_t *ptr = (const uint8_t *) 0x8000; uint8_t value; NVMCON1bits.NVMREGS = 1; value = *ptr; NVMCON1bits.NVMREGS = 0; return(value); } Any help is much appreciated, Alexander |
|
相关推荐
4个回答
|
|
|
是的,我知道,但是我希望代码反映IDLoc字节是14位,即使我只使用较低的8位。谢谢你的回应。
以上来自于百度翻译 以下为原文 Yes, I know, but I wanted the code to reflect that the IDLOC bytes are 14 bits, even though I only use the lower 8 bits. Thanks for your response though. uint8_t getIDLoc(uint8_t n) { bool GIEstate; uint16_t IDLocAddr; if (n > 3) { return(0); } else { IDLocAddr = 0x8000 + n; GIEstate = INTCONbits.GIE; INTCONbits.GIE = 0; while(INTCONbits.GIE); NVMCON1bits.NVMREGS = 1; NVMADR = IDLocAddr; NVMCON1bits.RD = 1; NVMCON1bits.NVMREGS = 0; INTCONbits.GIE = GIEstate; return(NVMDATL); } } |
|
|
|
|
|
我想我在什么地方读到需要禁用中断,但是数据表没有提到这一点,所以我猜你是对的。谢谢你的小费!
以上来自于百度翻译 以下为原文 I think I read somewhere that disabling interrupts was required, but the datasheet does not mention this, so I guess you are right. Thanks for the tip! uint8_t getIDLoc(uint8_t n) { uint16_t IDLocAddr; if (n > 3) { return(0); } else { IDLocAddr = 0x8000 + n; NVMCON1bits.NVMREGS = 1; NVMADR = IDLocAddr; NVMCON1bits.RD = 1; NVMCON1bits.NVMREGS = 0; return(NVMDATL); } } |
|
|
|
|
|
很高兴我能帮上忙。我将编码如下:
以上来自于百度翻译 以下为原文 Glad I can help. I would code that as: uint8_t getIDLoc(uint8_t n) { NVMADRL = n; NVMADRH = 0x80; NVMCON1bits.NVMREGS = 1; NVMCON1bits.RD = 1; return NVMDATL; } |
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1097浏览 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 07:48 , Processed in 0.852694 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1853