Hi ,
There's a problem about the MPC5634M Flash erase blocks in my MPC5634M project. I have integrated the SSD flash driver which is :Standard Software Driver v1.0.3 (xPC56xx_C90LC) in my code ,and the program running process is:
(1)Firstly ,erase the block 2 (address ;0x00008000),then write 96 bytes from address 0x00008000 ,write success.
(2)secondly,erase the block 3 (address ;0x00010000),then write from address 0x00010000 ,write success.
(3)I want to erase the block 2 (address ;0x00008000),and write 96 bytes from address 0x00008000 again ,the erase result seems is ok ,but I feel this erase operation is fail.
This fail case is : the return value of the Erase function is C90FL_OK ,but actually the block 2 which I want to erase is not erased . that means the last value still in the block 2. the all value didn't change to 0xFF .
I use the API is C-array FlashErase_C, which in the path : Freescale\Standard Software Driver v1.0.3\xPC56xx_C90LC\Driver\cw\vle\c-array_driver ,and the call function like this :
and the debug register I can see the block is unlock correct :
after executed the erase operation ,the returnCode is C90FL_OK ,but in the flash block 2 ,the value didn't be erased.
so I have 4 question about this case :
1.whether the SSD C-array FlashErase_C which I used is right ? what's the difference in BookE and vle.
2.The parameter like shadowFlag, lowEnabledBlocks, midEnabledBlocks, highEnabledBlocks of the function ,is it correct ?
pFlashErase( &ssdConfig, shadowFlag, lowEnabledBlocks, midEnabledBlocks, highEnabledBlocks, (tpfNullCallback)NULL_CALLBACK );
4.what do you have some suggestion to me ?
Hi,
do not write to ssdConfig like this:
During initialization phase, you are supposed to initialize the ssdConfig in this way (copied from demo code):
/* CFlash */
SSD_CONFIG ssdConfig = {
C_REG_BASE, /* Flash control register base */
C_ARRAY_BASE, /* base of main array */
0, /* size of main array */
SHADOW_ROW_BASE, /* base of shadow row */
SHADOW_ROW_SIZE, /* size of shadow row */
0, /* block number in low address space */
0, /* block number in middle address space */
0, /* block number in high address space */
C90FL_PAGE_SIZE_08, /* flash page size selection */
FALSE /* debug mode selection */
};
That's mentioned in user manual:
Then call FlashInit(). This function will read the flash configuration information from flash registers and it will initialize the rest of the parameters: mainArraySize, lowBlockNum, midBlockNum and highBlockNum.
You are not supposed to modify the ssdConfig anymore.
Then it should work.
Regards,
Lukas
Hi Lukas,
otherwise ,I use the following c_array:
I don't know what's the root cause ,and what about you ?
Hi Lukas,
I tried it on in accordance with your method,but still failed.
Following is my change point :
1. I have changed the SHADOW_ROW_BASE to 0x00FFC000 and SHADOW_ROW_SIZE to 0x00004000 follow the MPC5634M datasheet.
2. Remove the ssdConfig information ,and set the lowEnabledBlocks = 0x00000004uL;because I want to erase the block 1b(base address is 0x00008000) .
There is a problem :when set the lowEnabledBlocks = 0x00000004uL, the erase function pFlashErase will run away .
but I set the lowEnabledBlocks = 0x00000002uL, the erase function pFlashErase will return C90FL_OK, but still can't erase success .
From the above ,I am confused what value should set about the lowEnabledBlocks parameter ?
I check the MPC5634M manual ,there is a example :
the example erase blocks 2a and 1b ,the LMS=0x00000006;
but form the LMS register description if erase the blocks 2a and 1b,the LMS Should be equal to 0x0000000C.
is it right about my understanding ?
Hi,
where the code is running from? Notice that Read-While-Write is supported only between banks. For example, if you want to erase or program bank 0, the code must be executed either from bank1 or from RAM. That could be the reason.
Next thing - there are three flash arrays. If you want to program all of them, you need three instances of ssdConfig. Take a look at attached code. Notice that this example must be executed from RAM because it erase/program all arrays for test purposes.
To erase block 0, you need to set lowEnabledBlocks = 1;
To erase block 1a, you need to set lowEnabledBlocks = 2;
To erase block 1b, you need to set lowEnabledBlocks = 4;
To erase all these blocks, you need to set lowEnabledBlocks = 7;
That's a good point - there seems to be a typo in Example 10-2. I agree, there should be 0xC.
Regards,
Lukas
Hi Lukas,
I have found the root cause of my problem ,it's the watchdog.Disable the watchdog when erase the blocks the erase result is ok.Your example is correct .
Thank for your great support!
Hi ,
Today I Transplant the example code to my project ,and I close the other function .it means the project just the transplanted code .in the code I erase block 3(0x0001c000-0x00020000). The result seems same as my code .That means when erase the block ,the program will runway.And I check the memory the value is 0x00000000,seems not correct.you can see it in the following :
the code as the follow:
we can know the pFlashErase runing in the RAM ,right?
and the register:
LCF configuration:
In my thinking ,all the above information is ok ,but I don't know why the result is not correct ?
Could you help me double check the example code ,and if you have other ideas ,please let me know ,thank you !
Hi Lukas,
Thanks for your quick response,and I am sorry I forgot to tell you what 's my design idea.
1.The LCF configuration as follow :
This is the bootloader field :
2. As you said ,I have defined three instances of ssdConfig which like the example ..
3.And the code running from the RAM .I re-define the C-array drivers as variables (just delete “const”) and they will be automatically copied to RAM by startup code.
Here just the C-array drivers locate the Ram area , whether need to define the function which called the C-array drivers in the Ram area? For example ,in my project the function ;EraseFlash().
I will have a try with your example project if still erase failed .
Thank you very much !
Best Regards,
Dennis