Hi to all the community
I'm using a MKV31F256 in KDS 3.0 with Processor Expert
i got an unexpected behavior placing some parameters at programming time in a sector of Flash memory
especially compared to what i used to have in CW 10.5:
In a .c file i declared
__attribute__((section (".MyParamSector")))const unsigned int MyFlash2K [512]={ | 40,3400,4570,21,38..... |
In this way in KDS,at debug, the declared array MyFlash2K[512] is placed at correct address 0x3F800 but the Memory viewer shows that
the unsigned Int values are all =0xFFFFFFFF,instead of 0x28,0xD48...
in CW 10.5 i had the needed result simply with
unsigned int __attribute__((section (".MyParamSector"))) MyFlash2K [512]={ | 40,3400,4570,21,38..... |
I modified the ProcessorExpert.ld file to reserve the last 2 flash sectors for my non volatile parameters,
then i deflagged the "Generate linker file " option in the PE Build Options:
MEMORY {
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_interrupts_ram (RW) : ORIGIN = 0x1FFFC000, LENGTH = 0x00000400
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0003EBF0/*reduced by 2 x 0x800 to make room for my sectors*/
m_data (RW) : ORIGIN = 0x1FFFC400, LENGTH = 0x00003C00
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00008000
MyTableSector (RX) : ORIGIN = 0x0003F000, LENGTH = 0x00000800
MyFlashSector (RX) : ORIGIN = 0x0003F800, LENGTH = 0x00000800
}
/* Define output sections */
SECTIONS
{
.my_block0 0x0003F000 : /* placing my named section at given address: */
{
KEEP(*(.MyTable_Sector)) /* keep my variable even if not referenced */
} > MyTableSector
}
SECTIONS
{
.my_block1 0x0003F800 : /* placing my named section at given address: */
{
KEEP(*(.MyParamSector)) /* keep my variable even if not referenced */
} > MyFlashSector
}
There is something missing or wrong.
May i have some help,please?
Thank you
Diego
Hi
The only way i have found to have the start of the sector with initialized values{0x40,...etc) is to declare the array with size of 256 instead of 512.
The strange thing(at least strange to me) is that restoring the size of 512 the values are still initialized{0x40,,..etc)...
I can guess that it is because the memory is not erased at that address, unless the linker or the compiler decide to assign some value in that sector....in other words i'm still walking in the fog
By now
1)The project of Alice Yang(thanks once more) works for her,and not for me,if imported unaltered
2)If the const variable at absolute Flash address is of the size of the sector for me it does not initialize,if half size(or a quarter,or...)it does
3)The differences between my workbanch and her are apparently just a different programming tool,and maybe some setting in my KDS that remains unalterd importing Alice's project.
I hope that this clues are helping someone to solve my problem,and that it helps everyone else.
Thanks for your attention.
Diego
Hello Diego,
Does the the data of other flash memory is right ?
You can select the "Mass erase on connect" to erase the flash before download the project :
And yes, my project is a simple without any function , i only test the function for you said.
BR
Alice
Hello Diego,
In the linker file , does it have two "SECTIONS" words ? If yes , please write all of the sections under one "SECTIONS".
I refer to your code create one simple project about KV31F256, then test on my side , check the memory view , it correct :
The attachment is my project , you can check .
- Pay attention that , in the PE project , if you change the linker file by hand , not configure the PE ,
please disable the "Generate linker file " , then build the project .
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Alice,
thanks for acting so quickly in my help ,building and testing a project.
Despite your help ,once imported the project does not work for me.I still have the memory at 0xFFFFFFFF;
How can it be?
I forgot to say that i'm using a P&E Multilink as debugger and this should be the only difference,so i did a debug configuration for it.
There are no preserved areas in Advanced Options.
Selecting the device in the debugger window i have to choose MKV31F256M12, the closer to my MKV31F256VLL12 device.
Is this correct??Can it lead to any problem?
Of course i did not touch any PE settings,and even in my original project the "Generate linker file " option was not selected.
Thanks again for your hints and tests.
Diego
Hello again Alice
yes ,for what i can see my device downloads and works correctly.
This initialization was added on a project mounted on a prototype board,where i have a OLED display correctly driven through SPI,a RTCC communicating through I2C,and a GPIO pin useful to synchronize the oscilloscope.
I added few code and 1 component in your project to simply toggle 1 pin at a regular rate,and it toggles-
Are there some intermediate file that i could check to see the effect of the flash data declarations?
I dont know exactly how to check it in the generate elf files,or other file that is affected by the flash data declarations.
It would be interesting to go deeper inside,i think is that kind of analysys that Erich Styger sometimes does on his website,but i dont know if there is something similar to this particulare case in KDS
Thanks again for helping me
Diego