Other Parts Discussed in Thread: C2000WARE
不希望Green Deng回答!!!希望其他的工程师能回复一下。
有两个问题:1,调用FlashAPI 时,是否需要把整个程序搬移到RAM中运行?
2,这里读写操作和bootloader操作有什么区别吗?
3,不要再发链接,也不要说官方例程里有。
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
不希望Green Deng回答!!!希望其他的工程师能回复一下。
有两个问题:1,调用FlashAPI 时,是否需要把整个程序搬移到RAM中运行?
2,这里读写操作和bootloader操作有什么区别吗?
3,不要再发链接,也不要说官方例程里有。
不知道我是否理解了您的意思。若是没有正确理解的话,请您指出。
您现在是想将数据放到flash的指定位置?
若是需要将某个变量存放到某个特定的位置,则利用#pragma DATA_SECTION指令。
因为利用CCS进行芯片编程时,如果不指定变量的存储位置,那么编译器会自动给变量分配存储位置。
在下面的文档中有详细描述
感谢您的解惑,但我要的不是这个操作,我现在是想把can通信接受到的一些机器设定值存在flash中,掉电后仍然可以保存。这些设定值可以通过上位机用can随时来修改。您说的那种方式是不可以任意修改已经存好的数据。
1,调用FlashAPI 时,是否需要把整个程序搬移到RAM中运行?
使用flash api时 需要进行以下操作
1 Copy the Flash initialization code from Flash to RAM 即拷贝flash的初始化代码
2 Copy the Flash API from Flash to RAM
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/951668/faq-faq-on-flash-api-usage-for-c2000-devices
这些您可以参考例程内的拷贝方法
C:\ti\c2000\C2000Ware_3_04_00_00\driverlib\f28004x\examples\flash
我现在是想把can通信接受到的一些机器设定值存在flash中,掉电后仍然可以保存。
flash的话,上电不擦除的话,掉电是可以保存的
您可以使用下面的方法来写flash
// In this example, 0xFF+1 bytes are programmed in Flash Bank0 Sector6
// along with auto-generated ECC.
// // Fill a buffer with data to program into the flash. // for(i=0; i <= WORDS_IN_FLASH_BUFFER; i++) { Buffer[i] = i; } for(i=0, u32Index = Bzero_Sector6_start; (u32Index < (Bzero_Sector6_start + WORDS_IN_FLASH_BUFFER)) && (oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+= 8) { oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index, Buffer+i, 8, 0, 0, Fapi_AutoEccGeneration); // Wait until the Flash program operation is over while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors Example_Error(oReturnCheck); } // Read FMSTAT register contents to know the status of FSM after // program command to see if there are any program operation related errors oFlashStatus = Fapi_getFsmStatus(); if(oFlashStatus != 0) { //Check FMSTAT and debug accordingly FMSTAT_Fail(); } // Verify the programmed values. Check for any ECC errors. // The program command itself does a verify as it goes. // Hence program verify by CPU reads (Fapi_doVerify()) is optional. oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, Buffer32+(i/2), &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors Example_Error(oReturnCheck); } }
其中代码内的参数 Bzero_Sector6_start 即 Start address in Flash for the data and ECC to be programmed
您可以自己选择存放的地址。
这些设定值可以通过上位机用can随时来修改。
修改的话,也是可以通过上面的代码来擦除后重新写这段flash
若是这段地址内的数据需要一直不擦除(即使重新烧录程序),则可以使用下图内的选项来设置
感谢你的回答,susan yang,我目前就是这么处理的,但是有个问题,调用Example_CallFlashAPI这个函数,是否每次写入前都要清除整个section?我目前发现第一次数据可以写进去8个数据。我第二次在前8个数据的基础上接着写数据时,发现整个section,都被清除了。请问flash写之前的擦除section的操作是不是必须要步骤。还有写入的数据必须是32位的吗?
调用Example_CallFlashAPI这个函数,是否每次写入前都要清除整个section?
是的,您的理解是正确的。
Note that a sector should be erased before it can be reprogrammed.