Microchip
直播中

曹兵

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

PIC32MX530F128H NVM WritePage只有第一个128字节被写入一行

你好研究员,我困了,需要一些帮助与NVM程序闪存写页。我在论坛里发现了一些代码,我必须修改一下,以适应我的需要。现在模拟器里一切都很好。我可以擦除闪光灯页面并给它写。我必须写600字节。因此不止一行。据我所知,PIC32 MX中的行是512字节。我用最后两个程序Flash页面为我的用户闪存空间。我的用户Flash空间开始于0x9D01E000,结束于0x9D01FFFF。这应该是2×4096字节。我还保留了链接器脚本问题:当我写一行时,只有第一个128字节被写入一行。其余的行(80H-200小时)仍然是FFH。这是我使用的代码:MycPy((空*)PaBufff,(空虚*)用户闪存,sieZof(PaBufff));NVMyErasePoad((空*)UsFlash页面);……(NUBYTESLUT & GT;ByTeTyRoWig Simple)NyBestTestOrreTeToRoWo= BytEythRoWig大小;否则NuBestTestOWRITETROW= NuByTestLead;//从PaBufff写入512个字节(一个NVM行)。总是写一整行。//NvMyWrrrDeWORE((空洞*)(UsFlash页面+ RoRunnIn PaulBufff),(空虚*)PaBufff);/*原始*/Unt8Itt Res=NVMyWrdReWORE((空洞*)(UsFlash页面+ RoRunnIn PaulBufff),(空*)PaBuffff+RooRunnIn PaulBufff);= 0)返回Res;NuByTestLeop-= NuByTestOWrrTeToRoW;RooRunnIn PosiWoReTeToRoW;}和未签名的int nvMyWrdReWORE(无效*地址,空隙*数据){un签署int Res=0;未签名int SaveDeSt.;SaveDeStase=d int)地址和0x1FFFFFF;NVMSRCADDR=((未签名int)数据和0x1FFFFFF);RES=NVMME解锁(NvMyOptuthOpRead Err.Read);*一些帮助或提示将非常感谢。非常感谢,安德烈亚斯。

以上来自于百度翻译


      以下为原文

    Hello Fellows,
Im stuck and need some help with NVM Program Flash write page. I found some code here in the forum, which I had to modify a little bit to suit my needs. Now in simulator everything works well. I can erase the flash page and write to it. I have to write 600bytes. Hence more than a row. According to my knowledge a row is 512 bytes in PIC32MX. I use the last two program flash pages for my user flash space. My user flash space starts at 0x9D01E000 and ends at 0x9D01FFFF. This should be 2*4096bytes. I also reserve that in the linker script

Problem: When I write a row only the first 128byte are written of a row. The rest of the row (80h-200h) remains all FFh.
Here is the code I use:

memcpy((void *)pageBuff, (void *)userFlashPage, sizeof(pageBuff));
NVM_ErasePage((void *)userFlashPage);
...
while (numBytesLeft)
   {
      if (numBytesLeft > BYTE_ROW_SIZE)
         numBytesToWriteToRow = BYTE_ROW_SIZE;
      else
         numBytesToWriteToRow = numBytesLeft;
      // Write 512 bytes (one NVM row) from pageBuff. Writes a whole row always.
      //NVM_WriteRow((void *)(userFlashPage + rowIndexInPageBuff), (void*)pageBuff); /* Original */
      uint8_t res = NVM_WriteRow((void *)(userFlashPage + rowIndexInPageBuff), (void*)pageBuff + rowIndexInPageBuff);
      if (res != 0)
          return res;
      numBytesLeft       -= numBytesToWriteToRow;
      rowIndexInPageBuff += numBytesToWriteToRow;
   }

and
unsigned int NVM_WriteRow (void* address, void* data)
{
    unsigned int res = 0;
    unsigned int saved_state;
    saved_state = __builtin_get_isr_state();
    __builtin_disable_interrupts();
   
    NVMADDR = ((unsigned int) address & 0x1FFFFFFF);
    NVMSRCADDR = ((unsigned int) data & 0x1FFFFFFF);
    res = NVM_Unlock(NVM_OPERATION_WRITE_ROW);
   
    __builtin_set_isr_state(saved_state);    /* Set back to what was before. */
    return res;
}

Some help or hints would be very appreciated. Thank you very much.
Andreas

回帖(2)

李铭鑫

2018-9-30 15:49:14
嗨,我想这是RTFM的例子,不同的PIC32 m…家庭具有不同的Flash页面大小,而PIC32 MX530与其他PIC32 MX5XX设备实际上不是一个家庭,而是一个PIC32 MX230设备,具有一个从MX5设备借用的CAN总线外设,它具有PIC32 MX1xx和MX2XX设备的存储器,闪存页面大小为1024字节,256个指令字F。LASH行大小128字节,是32个指令字。参阅:DATSHETDS6601290E第63页第6章框架注释:。迈西尔

以上来自于百度翻译


      以下为原文

    Hi,
I think this is a case of RTFM.
 
Different PIC32M...   families have different Flash Page size, and
PIC32MX530 isn't really in family with other PIC32MX5xx  devices.
Instead, it is a PIC32MX230 device with a CAN bus peripheral borrowed from MX5 devices.
It have Memory as  PIC32MX1xx and MX2xx devices, with Flash Page size 1024 bytes, 256 Instruction words,
Flash Row size 128 bytes, is 32 Instruction words.
 
See: datasheet DS60001290E-page 63 chapter 6.0 the framed Note:.
 
   Mysil
举报

康志强

2018-9-30 15:57:31
谢谢你,Mysil,你说得对。我太专注于PIC32 FRM内存。现在一切都如愿以偿!

以上来自于百度翻译


      以下为原文

    Thank you Mysil, you are absolutely correct. I was too much focused on the PIC32FRM for the memory stuff. Now everything works as expected!
举报

更多回帖

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