CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Sep 20, 2019 7:10 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jul 10, 2019 3:55 pm 
Offline

Joined: Thu Jan 24, 2019 10:15 am
Posts: 8
Hi everyone,

Problem:
When my application crashes, a previously written variable will not be saved persistently.

Description:
I am currently implementing a checkpoint variable. It is supposed to show which checkpoint/section has been reached after a crash. With this I intend to find sections with code errors, which lead to crashes.
The variable is defined as global retain persistent. The first thing that happens when the program starts, is that this variable will be evaluated once and sent by CAN.
By now I have a method with which I can let my program crash. I used the method to test my checkpoint variable, if it is written properly after a crash.
Unfortunately, this is not the case. The last written and transmitted value is 5 segments old. So, the variable is written multiple times, in different segments, then is written a last time and then the program is being let crashed.
If I think about C/C++, what comes to my mind is the keyword 'volatile'.
There is only one task, so it will most likely not be a problem of multiprocessing.
I also added a loop with 1000 iterations for a test. It probably also doesn't have anything to do with code ordering/ optimization. (Notable is, this code is running on an operative system and is intended for diagnosis. So, it is not reasonable to wait 5ms after writing a checkpoint variable.)

Questions:
Is it possible, that this variable is being written to a cache before it is being put into the flash?
Is it possible to make a variable 'volatile'? ('volatile' in the meaning like in C, being written to the RAM/Flash without cache optimization)
Is there another possible reason for my problem?
Is there a flush-method to actively write to the flash, without any cache?
Is there a bread crumb register to write to, which is more reasonable for my purpose?

Best regards and thanks in advance


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: Andreas Kehrer and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited