1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在寻找一个代码示例来保存我的PIC32毫米的配置,由于某种原因,我找不到在内部PIC EEPROM中写入和读取的方法。试图找出是否有人已经找到了这样做的方法。
以上来自于百度翻译 以下为原文 I'm looking for a code example to save the configuration of my PIC32MM, for some reason I can't find a way to write and read in the internal PIC eeprom. Trying to find if someone have already found a way to do this. |
|
相关推荐
6个回答
|
|
你没有透露哪一个PIC32毫米,但据我所知,它们都没有内部EEPROM,你必须把它保存在内部闪存。你使用MCC还是和声?
以上来自于百度翻译 以下为原文 You didn't reveal which PIC32MM, but as far as I'm aware, none of them have internal EEPROM, you have to save it in internal FLASH. Are you using MCC or Harmony? |
|
|
|
我使用MCC,我使用PIC32 MM000 64 GPL028如何保存内部闪存而不丢失数据的风险?
以上来自于百度翻译 以下为原文 I'm using MCC, and I'm using the PIC32MM0064GPL028 How can I save in internal flash without the risk of losting the data? |
|
|
|
嗨,MCC还没有为PIC32毫米设备做任何事情。所有的PIC32毫米设备在写入闪存的数据方面都是一样的,设备之间的唯一区别是闪存的总大小。硬件在芯片中,并在数据表第5章中描述。注:表26-11:在数据表的规范部分。在家庭参考手册第5部分中有更多的描述。它是一个单独的文档,您可以从产品网页下载您的设备:HTTP://www. MyCHIP.COM/WWWORDSTMS/En/PIC32 MM00 64 GPL028打开:OnAb,在页面的最下面。在闪存中写两个单词的功能可能是这样的:问候,Mysil
以上来自于百度翻译 以下为原文 Hi, MCC have not yet done anthing to help with this for PIC32MM devices. All PIC32MM devices behave the same when it comes to writing data into Flash memory, the only difference between devices is the total size of flash memory. The hardware is in the chip, and is described in Datasheet chapter 5. Also note: TABLE 26-11: in the specifications part of the datasheet. There is more description in Family Reference Manual section 5. it is a separate document that you may download from the product webpage for your device: http://www.microchip.com/wwwproducts/en/PIC32MM0064GPL028 open the: > Documentation tab, far down in the page. A function to write two words in Flash memory may be like this: unsigned int NVM_WriteWord2(void* address, unsigned int data0, unsigned int data1) { unsigned int res = 0; NVMDATA0 = data0; NVMDATA1 = data1 /* convert virtual address to physical address and load into NVMADDR register */ NVMADDR = ((unsigned int) address & 0x1FFFFFFF); /* Unlock and Perform the NVM operation */ res = NVM_Unlock (NVM_OPERATION_WRITE_WORD); return res; } unsigned int NVM_Unlock (unsigned int nvmop) { unsigned int status = 0; /* Suspend or Disable all Interrupts */ asm volatile ("di %0" : "=r" (status)); /* clearing error bits before performing an NVM operation */ NVMCONCLR = NVM_NO_OPERATION_MASK; /* Enable Flash Write/Erase Operations and Select Flash operation to perform */ NVMCON = (NVM_WRITE_OR_ERASE_ENABLE_BIT | nvmop); NVMKEY = NVMKEY1; NVMKEY = NVMKEY2; /* Start the operation using the Set Register */ NVMCONSET = NVM_WRITE_CONTROL_BIT; /* Wait for operation to complete */ while (NVMCON & NVM_WRITE_CONTROL_BIT); /* Restore Interrupts */ if (status & 0x00000001) { asm volatile ("ei"); } else { asm volatile ("di"); } /* Disable NVM write enable */ NVMCONCLR = NVM_WRITE_OR_ERASE_ENABLE_BIT; /* Return WRERR and LVDERR Error Status Bits */ return (NVMCON & NVM_WRERR_LVDERR_MASK); } Regards, Mysil |
|
|
|
谢谢Mysil,我正在检查文档,但是我看不到读取设备中的数据的方法,有什么线索吗?
以上来自于百度翻译 以下为原文 Thanks Mysil, I'm checking the document, but I'm not seeing a way to read the data programmed in the device, any clue? |
|
|
|
它只是一个内存位置,没有特殊的方法需要。只需创建一个指向它的指针。
以上来自于百度翻译 以下为原文 It's just a memory location, no special method needed. Just create a pointer to it. int *PtrToNvm=0xbd001000;// or whatever address you use |
|
|
|
嗨,西蒙格123确实有这一点,但更多的是:在Flash程序存储器中写下一个顽皮的想法,而不告诉链接者你想把它放在哪里。这样做,将来会让你咬上一段时间,当程序变大时,你会集中精力做一些事情。因此,声明一个数组,其大小和对齐方式与您希望用于NVM存储的闪存页相同。如果安排内存有所有的位==1,即当设备被编程时,所有值为0xFFFFFFF,你可以一次用闪存写控制器写2个字,而不擦除。如果内存值为0x00亿或任何其他值,那么你必须清除整个PAG。在你可以存储任何东西之前,因为闪存只能在整个页面中被擦除:如果你需要存储一点数据,但是可能需要进行更新,那么在同一页面中存储新的更新信息,直到页面满了,只有当页面已经被删除时才是明智的。填充,而不是擦除,然后在同一地址写入新的数据。问候,Mysil
以上来自于百度翻译 以下为原文 Hi, simong123 have the point exactly, but there is more to this: It is generally a naughty idea to write in Flash program memory, without telling the linker what you want to place where. Doing so, will bite you some time in the future, when the program get larger and you concentrate on something completely unrelated. Thus, declare an array with the same size and alignment as the Flash memory page that you want to use for NVM storage. #define NUMBER_OF_INSTRUCTIONS_IN_PAGE 512 /* This is for PIC32MM, other devices have different page size. */ #define NVM_ADDRESS 0xBD003000 /* This is for PIC32MM, address should align with 0x800 or 0x000 */ volatile unsigned int nvmdata[NUMBER_OF_INSTRUCTIONS_IN_PAGE] __attribute__((section("nvm_data"), address(NVM_ADDRESS), space(prog))); If you arrange for the memory to have all bits == 1, that is all values 0xFFFFFFFF when the device is programmed, you may write 2 words at a time with the Flash memory write controller, without erasing. If the memory have value 0x00000000 or any other values, then you will have to Erase the whole page before you will be able to store anything. Since flash memory can only be erased in whole pages: If you need to store a little data, but may have to make updates, it may be smart to store new updates after each other in the same page, until the page is full, and only Erase when the page have been filled. Instead of erasing and then writing new data at the same address. Regards, Mysil |
|
|
|
只有小组成员才能发言,加入小组>>
5237 浏览 9 评论
2027 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3202 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
772浏览 1评论
662浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
590浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
672浏览 0评论
572浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 22:25 , Processed in 1.346441 second(s), Total 86, Slave 70 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号