LPC2148 RTC bug?

I’ve been having a problem with the RTC and power down mode on a project using the LPC2148.  I am using EINT3/INTWAKE and the RTC alarm as sources to wake the processor from power down and I find that occasionally, when I’m in power down mode,  the RTC peripheral seems to lock up and neither the alarm or EINT3 are able to wake the processor .  The only way to recover is to do a hard reset.
Searching for a solution, I found this post
http://www.embeddedrelated.com/groups/lpc2000/show/20665.php
that said to setup the PREINT and PREFRAC even if you are using an external RTC crystal.

PREINT = ( int )( ( 60000000UL / 32768UL ) – 1 ) & ( ( 1 << 14 ) – 1 );
PREFRAC = ( int )( 60000000UL – ( ( ( unsigned long )PREINT + 1UL ) * 32768UL ) );

I’ve just tried this on a few pieces of hardware that were consistently locking up in power down and it seems to be working so far. When I switch back and forth between firmware with and without those two lines it seems to follow that if I don’t set up PREINT and PREFRAC it locks up. If this is in fact the solution I would really like to know why this works since it makes no sense.

Leave a Reply

Your email address will not be published. Required fields are marked *