Unwritable RTC registers on MPC8308 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Unwritable RTC registers on MPC8308


I'm having trouble for days and I don't know what to do ... I'm working on a platform based on MPC8308 and trying to enable the uC RTC module in U-Boot. The problem is that when I try to write into these registers, their value is always 0x0 !!!

Here is the small code I wrote to configure the RTC registers, I also tried to write in RAM to see if this works ...:
#define RTC_BASE CONFIG_SYS_IMMR + 0x300
#define RTC_LDR RTC_BASE + 0x4
#define RTC_PSR RTC_BASE + 0x8
#define RTC_TR RTC_BASE + 0xC
#define RTC_EVR RTC_BASE + 0x10
#define RTC_ALR RTC_BASE + 0x14

void initRTC()

u32* volatile psr = RTC_PSR;
u32* volatile ldr = RTC_LDR;
u32* volatile cnr = RTC_CNR;
u32* volatile loadaddr = 0x800000;

u32 psr_value = 0x0;
u32 ldr_value = 0xABCD1234;
u32 cnr_value = (0x1 << 7);// | (1 << 24);
u32 loadValue = 0xBEEFABCD;

*psr = psr_value; // Divide clock by 1
*ldr = ldr_value; // Initial time
*cnr = cnr_value;// | (1 << 24);// Clock enable use, CSB clock
*loadaddr = loadValue;

printf("PSR pointer is 0x%08X, put 0x%08X and actually is 0x%08X
", psr, psr_value, *psr);
printf("LDR pointer is 0x%08X, put 0x%08X and actually is 0x%08X
", ldr, ldr_value, *ldr);
printf("CNR pointer is 0x%08X, put 0x%08X and actually is 0x%08X
", cnr, cnr_value, *cnr);
printf("loadaddr pointer is 0x%08X, put 0x%08X and actually is 0x%08X
", loadaddr, loadValue, *loadaddr);

Here is the output :
[code]PSR pointer is 0xE0000308, put 0x00000000 and actually is 0x00000000
LDR pointer is 0xE0000304, put 0xABCD1234 and actually is 0x00000000
CNR pointer is 0xE0000300, put 0x00000080 and actually is 0x00000000
loadaddr pointer is 0x00800000, put 0xBEEFABCD and actually is 0xBEEFABCD

When I manually try to write to these register with the debugger (Eclipse + Peedi), this has the same effect, the register stays at 0x0, except for the RAM location !

By the way, could someone explain me why the value of my pointers are wrong in my debugger ? I removed the -O2 optimization flag ...

I've been reading the MPC8308 datasheet for few days, trying a lot of different things, but now I'm running out of idea ... Maybe I'm missing something. Thanks for your precious advices !

Random Guy

Sign In or Register to comment.