Embedded / RTOS

Moderators: None (Apply to moderate this forum)
Number of threads: 373
Number of posts: 682

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Unwritable RTC registers on MPC8308 Posted by random_guy on 15 Dec 2010 at 2:24 AM
Hello,

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_CNR   RTC_BASE
#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\n", psr, psr_value, *psr);
  printf("LDR pointer is 0x%08X, put 0x%08X and actually is 0x%08X\n", ldr, ldr_value, *ldr);
  printf("CNR pointer is 0x%08X, put 0x%08X and actually is 0x%08X\n", cnr, cnr_value, *cnr);
  printf("loadaddr pointer is 0x%08X, put 0x%08X and actually is 0x%08X\n", loadaddr, loadValue, *loadaddr);
}


Here is the output :
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





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.