www.beck-ipc.com
www.beck-ipc.comwww.beck-ipc.com  | ImprintImprint
FAQFAQ  | SearchSearch  |
RegisterRegister   |LoginLogin

Base Address of the CoDeSys Retain Area

Questions and discussions about the CoDeSys SDK with the IPC@CHIP® plattform.
Hello,

I want to use the internal flash of the SC143 processor to store all CoDeSys Retain Data (2 KB) in my PFI handler. For this purpose I return RHI_NVR_POWERFAIL flag in RHI function and use the “hal_save_non_validate_data()” in my PFI handler.
At the beginning of my program I should call the “hal_init_non_validate()” function. But how can I find out the base address of the CoDeSys Retain Area which I should write to the segment field of the Remop structure?

Thanks a lot.

Hello,

if you want to use the internal NVS-RAM, you just have to return the flag "RHI_NVR_POWERFAIL" in the function RHICFGGetNonVolMemPolicy().

Returning this flag, leads to the fact that internal Retain functions of the Runtime
System are used. So it is not necessary to call any other functions in the myrts.c file.

best regards
Daniel Humburg
Software Development
Beck IPC GmbH

Postby Paul Elgershuizen » 22.11.2007, 16:10

Hello,

Please look in the prevous Thread titled: "Base memory address for CoDeSys memory space". its the same question and already answered.

Greetings,
Paul Elgershuizen
Beck-IPC GmbH.

Postby Alexander » 23.11.2007, 08:28

Hello,

Of course, I had read the previous Thread «Base memory address for CoDeSys memory space» before I posted this topic. But the answer has not satisfied me. It seems to me, than it is not enough to return the flag RHI_NVR_POWERFAIL only. Yes, the Retain data is saved after the software reset in CoDeSys, but not saved after I press «Reset» or «PFI» button on my DK60 board. That because I presumed that an advanced mechanism is required to store and restore the Retain data.

P.S. I use the 1.16 Beta RTS version.

Regards,
Alexander

Postby Paul Elgershuizen » 23.11.2007, 10:30

Hello,

If you are only using Retain variables in the IEC-Program, and you want to keep its values across a powerfail, Setting of the Powerfail Flag in the Policy function is enough.
This flag activates the "more advanced mechanism" as you call it, which has already been implemented in the RTS-kernel itself.
If you set the Powerfail flag, the PFI Interrupt service routine is installed by the RTS kernel. You should not install one yourself ! This PFI Handler uses the settings given in the Policy function to decide what to do. If the internal mechanism is used, it will call the hal_save_non_volatile () for you.
Also at startup time when the internal mechanism is used, the kernel will call the hal_non_volatile_init function for you.

I also read your reply in the thread "PowerFail doesn't work (saving/restoring remanent data)". This answers the question why your retains are not saved in case of a power fail. The retains area is initialised and restored before the IEC program is started. Redefining the PFI interrupt service routine after the program start event, means that in case of a powerfail not the original PFI service routine will be called, but your own. Result: the RTS internal mechanism implemented in the kernel is used to restore the data, and the mechanism you implemented yourself is used to save the data. This should be avoided. Again: Please comment out all Retain handling code you implemented yourself (including th entry in the CHIP.Ini file). Define only the Powerfail flag in the function RHICFGNonVolMemPolicy function. This should work in your case.

Please also note that using the reset button, does not generate a powerfail interrupt.

greetings,
Paul Elgershuizen
Beck-IPC GmbH.

Postby Alexander » 23.11.2007, 11:42

Hello, Paul,

I tried to delete the entry PFI_ENABLE=1 in the CHIP.INI file and all Retain handling code in myrts.c, except setting the Powerfail Flag. But I got the same result!

Regards,
Alexander.

Postby Paul Elgershuizen » 23.11.2007, 14:25

Hello Alexander,

Could you please send me your IEC-Platform (TSP and RTS), so i can have a look at the problem you have, I think i may be able to help you in a more efficient way.

You can use my email address from my profile.

Greetings,
Paul Elgershuizen
Beck-IPC GmbH.

Return to CoDeSys SDK


Who is online

Users browsing this forum: No registered users and 2 guests


cron