I'm currently trying to transfer some RTC code from the 52235 CPU to the 52259 CPU.
Getting the RTC in the 52235 running is easy as can be - just write MCF_CLOCK_RTCDR with the appropriate value and the RTC starts running.
Doing the same in the 52259 doesn't appear to be enough though - probably because the RTC in the 52259 can have several sources as reference.
I just want the RTC in my 52259 to run from the main 48MHz crystal reference, but I can't figure out how and don't have the data sheets available (and they can't be found on the freescale web site either right now!).
So please, can anyone help me out?
Thanks in advance!
Hi Marc
This is the initialisation code that I have for running from the oscillator directly:
RTCCTL = RTC_ENABLE;
MCF_CLOCK_RTCCR = 0; // select system clock for RTC
RTCGOCU = (unsigned short)((CRYSTAL_FREQ) >> 16);
RTCGOCL = (unsigned short)(CRYSTAL_FREQ);
where
#define RTC_ENABLE 0x00000080 // enable the RTC
and
#define CRYSTAL_FREQ 48000000 // 48 MHz oscillator / crystal input
It seems as though there are presently some problems with various documents on the web site so I have sent you the data sheet and user's manual to your private email address.
Regards
Mark
Mark,
(I couldn't figure out how to send you a private message.)
If possible, would you please send me the 52259 Datasheet? My latest copy of the MCF52259RM ref manual is Rev.1 2/2009 so send that too if you have a newer version. Hopefully, clicking on my profile name will allow you to send me an email. Thank-you.
Tim
Hello Tim,
I just sent you a private message.
Regards - Marc
Thanks for your help Mark!
Unfortunately it is still not running... I'm not sure what's going on or what I am doing wrong. This is my current startup code... (Coldfire Lite based)
void mcf52259_init(void) { MCF_GPIO_PDDPAR = 0x0F; //enable pst[0..3] /* * Set Port UA to initialize URXD0/UTXD0 */ MCF_GPIO_PUAPAR = 0 | MCF_GPIO_PUAPAR_URXD0_URXD0 | MCF_GPIO_PUAPAR_UTXD0_UTXD0; MCF_GPIO_PUBPAR = 0 | MCF_GPIO_PUBPAR_URXD1_URXD1 | MCF_GPIO_PUBPAR_UTXD1_UTXD1; mcf52259_wtm_init(); mcf52259_pll_init(); /* Set real time clock freq */ MCF_CLOCK_RTCCR = 0; // select RTC clock source MCF_RTC_RTCGOCU = (unsigned short)((48000000 / 6) >> 16); MCF_RTC_RTCGOCL = (unsigned short)(48000000 / 6); MCF_RTC_RTCCTL = MCF_RTC_RTCCTL_EN; // enable RTC mcf52259_scm_init(); mcf52259_ccm_init(); mcf52259_gpio_init(); #ifdef M52259EVB mcf52259_mb_init(); #endif uart_init(0); uart_init(1); mcf52259_powerup_config(); mcf52259_ePHY_init(); // mcf52259_wtm_config(); //FSL added this function...reference M52233DEMO code }
I tried changing the order of the instructions but it didn't make any difference.
I can write the time in the RTC and read it back correctly, but it is never updated.
I only read the hours/minutes register of the RTC by the way, and set the seconds register to 0 when the hours/minutes are written into the register.