Microchip
直播中

王璨

7年用户 279经验值
私信 关注
[问答]

如何在PIC32MM中写入/读取int数字或字符并在加电时重新加载?

我正在寻找一个代码示例来保存我的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)

王焕树

2019-5-8 15:31:34
你没有透露哪一个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?
 
举报

任黎平

2019-5-8 15:47:46
我使用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?
举报

李铭鑫

2019-5-8 15:53:18
嗨,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
 
举报

任黎平

2019-5-8 15:59:59
谢谢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?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分