Content originally posted in LPCWare by toniojesusde on Wed Jan 19 05:02:03 MST 2011
Hi,
I am trying to use the RTC (Real time clock) in the LPC1769 xpresso board.
So i develop a little piece of code to try it out:
//RTC initialization:
[SIZE=2][LEFT]LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= !0x01|0x02;[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]//enable RTC clock[/LEFT]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][LEFT]LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]CCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x02;
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DOY[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=0;
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]HOUR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=0;
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MIN[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=0;[/LEFT]
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]SEC[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]=0;[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]//showing the time:[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][SIZE=2][LEFT]debug_printf([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"RTC : %2.2d:%2.2d:%2.2d:%2.2d\n"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]DOY[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]HOUR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],
LPC_RTC->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MIN[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2],[/LEFT]
LPC_RTC->[U]SEC[/U]);
When I do this, i get strage numbers in the console. DOY, HOUR, MIN and SEC , all of them increment each second.
So I end up reading:
[SIZE=2][LEFT]RTC : 0: 0: 0: 0
RTC : 1: 1: 1: 1
RTC : 2: 2: 2: 2
RTC : 3: 3: 3: 3[/LEFT]
...
I have checked all the registers associated to the RTC but all of them seem to be properly configured. Also, I looked at the registers of sec, min, hour, ... in the RTC peripheral registers, and they show the same erratic behaviour. What can be wrong? Some help would be appreciated.
Thanks a lot,
Antonio
[/SIZE]
[/SIZE][/SIZE]