Hi, I am working with Qorivva Power Arctechture and CodeWarrior. In my program I have declared some fixed constants, like calibrations constants. I have used "const int" to allocate it in flash memory with some non-volatile value. After recalibration process I want to change the value of this variables. My example code is:
#include <string.h>
#include "MPC5634M_MLQC80.h"
const int my_map_ROM[4]; // constant calibration map (FLAXH)
volatile int my_map_RAM[4] = {2,1,0,0}; // volatile calibration map (RAM)
int main(void)
{
int count=0;
volatile char desvio = 0; // change manualy to call different tasks
volatile int a=1, b=0, x; // change manually for debug
int y = ~0; // see result
while(1)
{
switch(desvio)
{
case 1: // Load data Flash2RAM in the begining
memcpy( (void *)my_map_RAM[0], (const void *)my_map_ROM[0], 4*sizeof(int) );
desvio = 0;
break;
case 2: // Load RAM data to local variables
a = my_map_RAM[0];
b = my_map_RAM[1];
desvio = 0;
break;
case 3: // Change RAM values for other tasks
my_map_RAM[0] = a;
my_map_RAM[1] = b;
desvio = 0;
break;
case 4: // Save data RAM2Flash for energy fault
memcpy( (void *)my_map_ROM[0], (const void *)my_map_RAM[0], 4*sizeof(int) );
desvio = 0;
break;
default:
y = a*x +b;
}
count++;
}
}
"case 2" and "case 3" are OK, but "case 1" and "case 4" does not work properly.
Original Attachment has been moved to: Project_VarConst.zip
Original Attachment has been moved to: Installed-Plugins.TXT.txt.zip