Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

RTC problem

RTC problem

2005-07-21 by swanann2000

Hi all!

Anyone can post a source code for the RTC of lpc2138 usign interrupts,
I have a lot of problems because the counter flag interrupt doesn't
appear, so the vector interrupt can never be generated.

I have use the application note from philips (AN10382 Using the RTC
efficiently in the LPC213x) but it doesn't work. 

Thanks in advance!

Re: RTC problem

2005-07-21 by swanann2000

--- In lpc2000@yahoogroups.com, "swanann2000" <swanann2000@y...> wrote:
> Hi all!
> 
> Anyone can post a source code for the RTC of lpc2138 usign interrupts,
> I have a lot of problems because the counter flag interrupt doesn't
> appear, so the vector interrupt can never be generated.
> 
> I have use the application note from philips (AN10382 Using the RTC
> efficiently in the LPC213x) but it doesn't work. 
> 
> Thanks in advance

Ok, I have just seen that the source code from the app note AN10382 is
wrong. The PCONP must be initialized to 0x1517BE, and also they don't
enable the general interrupt.

Re: RTC problem

2005-07-21 by Owen Mooney

I think this is most of it below.

The RTC is fairly cool. You can set EXTWAKE so that it wakes the 
processor up from power down every second
i.e processing available every second (or other external interrupt)  but 
with 10 uA power consumptions.

Owen Mooney

#define BIT0     0x00000001
#define BIT1     0x00000002
#define BIT2     0x00000004
... etc

// 2138 interupt sources

#define    WDT_NUM  0
#define TIMER0_NUM  4
#define TIMER1_NUM  5
#define  UART0_NUM  6
#define  UART1_NUM  7
#define   PWM0_NUM  8
#define   I2C0_NUM  9
#define   SPI0_NUM 10
#define   SPI1_NUM 11
#define    PLL_NUM 12
#define    RTC_NUM 13
#define  EINT0_NUM 14
#define  EINT1_NUM 15
#define  EINT2_NUM 16
#define  EINT3_NUM 17
#define     AD_NUM 18
#define   I2C1_NUM 19
#define    BOD_NUM 20

// 2138 interupt sources as bit masks

#define    WDT_BIT  BIT0
#define TIMER0_BIT  BIT4
#define TIMER1_BIT  BIT5
#define  UART0_BIT  BIT6
#define  UART1_BIT  BIT7
#define   PWM0_BIT  BIT8
#define   I2C0_BIT  BIT9
#define   SPI0_BIT BIT10
#define   SPI1_BIT BIT11
#define    PLL_BIT BIT12
#define    RTC_BIT BIT13
#define  EINT0_BIT BIT14
#define  EINT1_BIT BIT15
#define  EINT2_BIT BIT16
#define  EINT3_BIT BIT17
#define     AD_BIT BIT18
#define   I2C1_BIT BIT19
#define    BOD_BIT BIT20


  // setup the Interrupt vectors
  // done in a group so as not to double up on any registers or lines
  // in order of priority
  // RTC Timer highest priority
  VICIntSelect &= ~RTC_BIT; 
  VICIntEnable = RTC_BIT;
  VICVectCntl0 = 0x20+RTC_NUM;
  VICVectAddr0 = (unsigned int)RTCISR;



static void RTCISR(void) __attribute__ ((interrupt ("IRQ")));
static void RTCISR(void) {
  int c;
  // clear interrupt
  c=ILR;
  ILR=1;
 ... code
  // Update VIC priorities
  VICVectAddr = 0;
}

static void initRTC(void) {
   CCR=0;         // disable
   CIIR=BIT0;      // 1 sec interrupt
   AMR=0;
   CCR=BIT0+BIT4; // enable + from Xtal
}

Re: RTC problem

2005-07-22 by Dave

--- In lpc2000@yahoogroups.com, Owen Mooney <ojm@s...> wrote:
> I think this is most of it below.
> 
> #define BIT0     0x00000001
> #define BIT1     0x00000002
> #define BIT2     0x00000004
> ... etc
> 
> // 2138 interupt sources
> 
> #define    WDT_NUM  0
> #define TIMER0_NUM  4
> #define TIMER1_NUM  5
> #define  UART0_NUM  6
> 
> // 2138 interupt sources as bit masks
> 
> #define    WDT_BIT  BIT0
> #define TIMER0_BIT  BIT4
> #define TIMER1_BIT  BIT5
> #define  UART0_BIT  BIT6

Hello,

  try this:

#define WDT_BIT     (1 << WDT_NUM)
#define TIMER0_BIT  (1 << TIMER0_NUM)
#define TIMER1_BIT  (1 << TIMER1_NUM)
#define UART0_BIT   (1 << UART0_NUM)

 etc...

Dave

RTC problem

2005-11-27 by r_bottleneck

Hello,

I  have a stupid problem with the LPC2138 RTC.

The RTC works with my SW on an Olimex EVB perfectly . However, I
designed an own board and the same SW doesn't start the RTC .

I checked the new board several times it seems to be ok. Also I
checked several different  crystals, as well as different capacitors
without success.VBat is supplied correctly. Even if the RTC clock is
supplied by the internal clock, the RTC does not work.

Is there something I forgot to take care ?

Thanks for any help.

RE: [lpc2000] RTC problem

2005-11-27 by Dan Beadle

Sounds like a software problem to me - 

 

On the Olimex board, are you starting up from zero in RAM? (Is there a
chance that something else starts up the RTC enable bit)

 

If identical software, running from flash, then it must be hardware.

 

I used the RTC on the '48 and it came up just fine.  You have to :

 

- Set PCONP.P09          RTC Power control bit.  (reset value in '48)

- CCR.P0 = 0                 // enter program mode

- CCR.P1 = 1                 // reset clock

- CCR.P1 = 0                 // allow to run

- CCR.P2 = 0;

- CCR.P3 = 0;                

. CCR.P4 = 1;                // ext osc...

- CCR.P0 = 1;                // Run.

 

You should be able to scope the RTC pins and see the signal 

 

 

 

  _____  
Show quoted textHide quoted text
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf
Of r_bottleneck
Sent: Sunday, November 27, 2005 7:30 AM
To: lpc2000@yahoogroups.com
Subject: [lpc2000] RTC problem

 

Hello,

I  have a stupid problem with the LPC2138 RTC.

The RTC works with my SW on an Olimex EVB perfectly . However, I
designed an own board and the same SW doesn't start the RTC .

I checked the new board several times it seems to be ok. Also I
checked several different  crystals, as well as different capacitors
without success.VBat is supplied correctly. Even if the RTC clock is
supplied by the internal clock, the RTC does not work.

Is there something I forgot to take care ?

Thanks for any help.









SPONSORED LINKS 

Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2
=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=9
3&.sig=tsVC-J9hJ5qyXg0WPR0l6g>  

Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&
w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s
=93&.sig=DvJVNqC_pqRTm8Xq01nxwg>  

Pic microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microproces
sor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c
=4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ>  

8051 microprocessor
<http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocess
or&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=
4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A>  

 

 

 

  _____  

YAHOO! GROUPS LINKS 

 

*	 Visit your group "lpc2000
<http://groups.yahoo.com/group/lpc2000> " on the web.
	  
*	 To unsubscribe from this group, send an email to:
	 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
	  
*	 Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 

 

  _____  



[Non-text portions of this message have been removed]

Re: RTC problem

2005-12-01 by r_bottleneck

Hello,

I still have the problem that the RTC is not working on my new board.
However, I found,  the RTC is working with internal clock, in opposite 
I mentioned in my start message. So there must be a problem with the
32Khz oscillator internally or externally.

I can not swap the LPC2138, because I have just a single board and
I dont want to kill it while un-soldering the CPU.

Is it possible to do a basic test to check if the oscillator is ok ? 
I mean it must be something like an inverter and there is an input and
output pin.

Does anbody know how the oscillator of the LPC2138 internally looks 
like? 

What can prevent the 32kHz oscillator from working internally?

Thanks

Re: [lpc2000] Re: RTC problem

2005-12-01 by Tom Walsh

r_bottleneck wrote:

>Hello,
>
>I still have the problem that the RTC is not working on my new board.
>However, I found,  the RTC is working with internal clock, in opposite 
>I mentioned in my start message. So there must be a problem with the
>32Khz oscillator internally or externally.
>
>I can not swap the LPC2138, because I have just a single board and
>I dont want to kill it while un-soldering the CPU.
>
>Is it possible to do a basic test to check if the oscillator is ok ? 
>I mean it must be something like an inverter and there is an input and
>output pin.
>
>Does anbody know how the oscillator of the LPC2138 internally looks 
>like? 
>
>What can prevent the 32kHz oscillator from working internally?
>
>  
>
If you have a scope, you would see about 1v p-p signal there, at least 
on my board.  Two can stop the RTC from running, the PCON settings and 
the CCR.  My setup looks like this:

============= begin ==============
static inline void sleepClock(void)
{// place RTC on 32kHz xtal and disconnect power.
   RTCCCR = (CCR_CLKEN | CCR_CLKSRC);
      // power off the clock registers.
   PCONP &= ~PCRTC;
}

static inline void awakenClock(void)
{// prepare clock for interactive use.
   RTCCCR = (CCR_CLKEN | CCR_CLKSRC);
      // power up the clock registers.
   PCONP |= PCRTC;
}

void initRTC(void)
{
#ifdef HAS_CLOCK
bool nonsense = False;
rtcCTIME0_t ctime0;
rtcCTIME1_t ctime1;
rtcCTIME2_t ctime2;
struct tm newTime;
time_t resetTime;
   awakenClock();
      // see if clock contains nonsense values.
      // grab time as consolidated to avoid misses.
   ctime0 = RTCCTIME0; ctime1 = RTCCTIME1; ctime2 = RTCCTIME2;
      // leisurely tear the packed time apart into individual time.
   if ((ctime0.seconds < 0) || (ctime0.seconds > 59)) nonsense = True;
   if ((ctime0.minutes < 0) || (ctime0.minutes > 59)) nonsense = True;
   if ((ctime0.hours < 0) || (ctime0.hours > 23)) nonsense = True;
   if ((ctime1.dayOfMonth < 1) || (ctime1.dayOfMonth > 31)) nonsense = True;
   if ((ctime1.month < 1) || (ctime1.month > 12)) nonsense = True;
   if ((ctime1.year < 1980) || (ctime1.year > 2050)) nonsense = True;
   if ((ctime0.dayOfWeek < 0) || (ctime0.dayOfWeek > 6)) nonsense = True;
   if ((ctime2.dayOfYear < 0) || (ctime2.dayOfYear > 366)) nonsense = True;
   sleepClock ();
   if (nonsense) {
      // set the clock to Jan 1, 2006 00:00:00
      resetTime = 1136073600l;
      localtime_r (&resetTime, &newTime);
      newTime.tm_year += 1900;
      newTime.tm_mon += 1;
      newTime.tm_yday += 1;
      writeRTC (&newTime);
   }
#endif
      // start realtime heartbeat (1ms period).
   startMsTimer();
}

void readRTC (struct tm *theTime)
{// read clock registers and return tm structure.
#ifdef HAS_CLOCK
rtcCTIME0_t ctime0;
rtcCTIME1_t ctime1;
rtcCTIME2_t ctime2;
   awakenClock();
      // grab time as consolidated to avoid misses.
   ctime0 = RTCCTIME0; ctime1 = RTCCTIME1; ctime2 = RTCCTIME2;
      // leisurely tear the packed time apart into individual time.
   theTime->tm_sec = ctime0.seconds;
   theTime->tm_min = ctime0.minutes;
   theTime->tm_hour = ctime0.hours;
   theTime->tm_mday = ctime1.dayOfMonth;
   theTime->tm_mon = ctime1.month;
   theTime->tm_year = ctime1.year;
   theTime->tm_wday = ctime0.dayOfWeek;
   theTime->tm_yday = ctime2.dayOfYear;
   theTime->tm_isdst = False;
   sleepClock ();
#endif
}

void writeRTC (struct tm *newTime)
{// set clock to new values.
#ifdef HAS_CLOCK
   awakenClock();
      // grab time as consolidated to avoid misses.
   RTCTCR->seconds = newTime->tm_sec;
   RTCTCR->minutes = newTime->tm_min;
   RTCTCR->hours = newTime->tm_hour;
   RTCTCR->dayOfMonth = newTime->tm_mday;
   RTCTCR->month = newTime->tm_mon;
   RTCTCR->year = newTime->tm_year;
   RTCTCR->dayOfWeek = newTime->tm_wday;
   RTCTCR->dayOfYear = newTime->tm_yday;
   sleepClock ();
#endif
}

============= snip ===============


I know that was a lot of code, but I figured that you might get what you 
need from it?  Those routines are written to interface with newlib stubs.

Note that in the readRTC() & writeRTC() functions that I "power up" the 
clock interface, do the work, then put it to sleep?  Well, I've found 
that if you leave the clock powered all the time, you run the risk of 
jumbling the time contents when the board is power-cycled.  Since I've 
done the sleep / awake routines, the clock has kept it's time and is 
always accessible.

Regards,

TomW

-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------

RE: [lpc2000] Re: RTC problem

2005-12-01 by Dan Beadle

Have you tried an oscilloscope to look at it?  Normally, you should see
a low voltage signal - a sine wave about 1Vpp at 32K.

 

If no signal...

-          swap in the crystal from your demo board

-          swap in the caps from the demo board 

-          check for shorts in the crystal circuit.

 

 

You are right - the internal structure of the circuit is basically just
an inverter - the output the input both go to the cap. The ends of the
crystal also go thru the caps to ground (the tank circuit)  See the data
sheet for details.   Three external parts.  So you either have the
circuit wrong, board laid out wrong, the wrong parts, or defective parts
- this is very simple circuit

 

  _____  
Show quoted textHide quoted text
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf
Of r_bottleneck
Sent: Wednesday, November 30, 2005 11:04 PM
To: lpc2000@yahoogroups.com
Subject: [lpc2000] Re: RTC problem

 


Hello,

I still have the problem that the RTC is not working on my new board.
However, I found,  the RTC is working with internal clock, in opposite 
I mentioned in my start message. So there must be a problem with the
32Khz oscillator internally or externally.

I can not swap the LPC2138, because I have just a single board and
I dont want to kill it while un-soldering the CPU.

Is it possible to do a basic test to check if the oscillator is ok ? 
I mean it must be something like an inverter and there is an input and
output pin.

Does anbody know how the oscillator of the LPC2138 internally looks 
like? 

What can prevent the 32kHz oscillator from working internally?

Thanks






SPONSORED LINKS 

Microprocessor
<http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microprocessor&w2
=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s=9
3&.sig=tsVC-J9hJ5qyXg0WPR0l6g>  

Microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microprocessor&
w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=4&s
=93&.sig=DvJVNqC_pqRTm8Xq01nxwg>  

Pic microcontrollers
<http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microproces
sor&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c
=4&s=93&.sig=TpkoX4KofDJ7c6LyBvUqVQ>  

8051 microprocessor
<http://groups.yahoo.com/gads?t=ms&k=8051+microprocessor&w1=Microprocess
or&w2=Microcontrollers&w3=Pic+microcontrollers&w4=8051+microprocessor&c=
4&s=93&.sig=1Ipf1Fjfbd_HVIlekkDP-A>  

 

 

 

  _____  

YAHOO! GROUPS LINKS 

 

*	 Visit your group "lpc2000
<http://groups.yahoo.com/group/lpc2000> " on the web.
	  
*	 To unsubscribe from this group, send an email to:
	 lpc2000-unsubscribe@yahoogroups.com
<mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
	  
*	 Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 

 

  _____  



[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.