Dear all,
I was trying to implement overlay ram code , but its not working.
1)Controller i am using is MPC5744P
2)I tried the example code from this link.
3) I also tried implement this code in my existing code also.
In all the cases its not working.Is there anything i am missing.
i use 0x4000000 as the overlay SRAM. when i change the RAM value. the corresponding flash follows. but after Reset. flash backs to 0xffffffff
hello ,when i use this code ,it seems working fine,but after reset the flash value is still 0xffffff,how could this happen?
Hi,
this is copied from reference manual:
That means you can use any address within RAM implemented on this device (0x40000000 -- 0x4005FFFF).
Regards,
Lukas
Hello Lukas,
Thanks for the quick response. Now I'm trying to use the overlay with the function below. To my understanding it should copy the part of flash i chose to the location in SRAM i also defined, but nothing gets copied.
void Overlay(void)
{
PFLASH.PFCRD[0].Word0.B.LSTARTADDR = (Mirror_Small_Flash_Memory_Block_0_BEGIN>>4);
PFLASH.PFCRD[0].Word1.B.PSTARTADDR = (0x40010000>>4);
PFLASH.PFCRD[0].Word2.B.CRDSize = B64;
PFLASH.PFCR1.B.RWSC = 0b0101;
PFLASH.PFCR1.B.APC = 0b010;
C55FMC.MCR.B.PGM = 1;
*(unsigned int *)Small_Flash_Memory_Block_0_BEGIN = 0xffffffff;
C55FMC.MCR.B.PGM = 0;
PFLASH.PFCRDE.B.CRD0EN = 1;
PFLASH.PFCRCR.B.GRMEN = 1;
}
Mirror_Small_Flash_Memory_Block_0_BEGIN is defined as 0x08F98000, and Small_Flash_Memory_Block_0_BEGIN as 0x00F98000. B64 is 0b00110 just for testing a small transfer. Is there something additional i need to do or change in order for this to work?
Best regards,
Ivan Mandić
Hi,
I did quick test in debugger:
I configured descriptor 0 to overlay 32 bytes of flash at address 0x08F98000 by RAM at 0x40010000. When I enable the descriptor, I can see the RAM content at flash address:
If I disable the overlay, I can see original content (all 0xFF) at 0x08F98000:
Please check my configuration.
By the way, this piece of code:
C55FMC.MCR.B.PGM = 1;
*(unsigned int *)Small_Flash_Memory_Block_0_BEGIN = 0xffffffff;
C55FMC.MCR.B.PGM = 0;
... doesn't make sense. When you enable the overlay, it does not copy any data. It just re-map the RAM, so you see the RAM at flash addresses. If you want to see the flash again at the same addresses, you have to disable the overlay.
Regards,
Lukas
Hi Lukas,
I too have the same use case and I just followed your step, but not successful. but my target is MPC5777M Microcontroller.
When I try to set the PFCRD0_WORD0 & PFCRD0_WORD1 there is >> 4-bit shifting is happening, but I couldn't able to see this behavior in your screenshot.
Hello again,
I looked at your configuration and saw that i haven't set M0EN as '1'. That basically fixed my problem. The part of the code that doesn't make sense is used for safety measurement if there will be the use of line read buffer.
Thanks for the help again.
Best regards,
Ivan Mandić
That's a good point! I didn't notice this note in RM. Thanks for sharing.
Regards,
Lukas