AnsweredAssumed Answered

problem map a struct to Backup registers

Question asked by gnoss.juergen on Apr 1, 2013
Latest reply on Apr 1, 2013 by Clive One

I got a problem map a struct to Backup registers

what I do is:

/******************************************************************************************/
typedef struct {
    uint16_t actPageNo;
    uint16_t sollQTY;
    uint16_t lcd_BackLight;
    uint16_t lcd_Contrast;
    uint16_t rpm_Ticks;
    uint8_t actProfile;
    uint8_t dummy;
} processData_t;

#define ProcessData        ((processData_t *)(RTC_BASE + 0x50))



void init_ProcessData(void){
    init_RTC();
}

void processData_SetDefaultValues(void){
    ProcessData->actPageNo = 1;
    ProcessData->sollQTY = 200;
    ProcessData->lcd_BackLight = 5000;
    ProcessData->lcd_Contrast = 750;
    ProcessData->rpm_Ticks = 512;
    ProcessData->actProfile = 16;
    ProcessData->dummy = 0;
};


    processData_SetDefaultValues();

uint32_t r = 0;
uint8_t t = 0;

    for (t = 0; t < 5; t++) {
        r = RTC_ReadBackupRegister(t);
        tfp_sprintf(ss,"\r\nbefore  %d = %u %X\r\n", t,r, r);
        uart1_puts(ss);
    }
    tfp_sprintf(ss,"\r\nbefore   aPro %d aPa %u sPa %u B %u C %u \r\n",
    ProcessData->actProfile,
    ProcessData->actPageNo,
    ProcessData->sollQTY,
    ProcessData->lcd_BackLight,
    ProcessData->lcd_Contrast
    );
    uart1_puts(ss);

    r = (5000 << 16) | 750;
    RTC_WriteBackupRegister(RTC_BKP_DR1, r);

    for (t = 0; t < 5; t++) {
        r = RTC_ReadBackupRegister(t);
        tfp_sprintf(ss,"\r\nafter  %d = %u %X\r\n", t,r, r);
        uart1_puts(ss);
    }
    tfp_sprintf(ss,"\r\nafter  aPro %d aPa %u sPa %u B %u C %u \r\n",
          ProcessData->actProfile,
          ProcessData->actPageNo,
          ProcessData->sollQTY,
          ProcessData->lcd_BackLight,
          ProcessData->lcd_Contrast );
    uart1_puts(ss);        
 
/******************************************************************************************/

but result while setting values using the struct is not as expected:


before  0 = 13107400 C800C8

before  1 = 49152750 2EE02EE

before  2 = 0 0

before  3 = 0 0

before  4 = 0 0

before   aPro 0 aPa 200 sPa 200 B 750 C 750


while building my own 32Bit value and writing it to the register
using StdPerphLib function and read the data back using struct works just fine

after  0 = 13107400 C800C8

after  1 = 327680750 138802EE

after  2 = 0 0

after  3 = 0 0

after  4 = 0 0

after  aPro 0 aPa 200 sPa 200 B 750 C 5000

I use codesourcery toolchain

Any idea what's happening there?

Outcomes