Sign in

username:

password:



Not a member?

Search lpc2000



Search tips

Subscribe to lpc2000



lpc2000 by Keywords

2106 | ADC | ARM7 | Atmel | Bootloader | CAN | CrossStudio | CrossWorks | DDS | ECos | Ethernet | ETM | FIFO | FLASH | FPGA | GCC | GDB | GNU | GNUARM | GPIO | I2C | IAP | IAR | JTAG | Kickstart | LCD | Linux | LPC | LPC-E2294 | LPC2000 | LPC2100 | LPC2104 | Lpc2106 | Lpc210x | LPC2114 | LPC2119 | LPC2124 | LPC2129 | Lpc2138 | LPC213x | LPC21xx | LPC2210 | LPC2212 | LPC2214 | LPC2292 | LPC2294 | LPC2xxx | LPC3128 | MCB2100 | Olimex | Philips | PWM | Rowley | RTC | RTOS | SPI | SSP | UART | UART0 | UART1 | ULINK | USB | Watchdog | Wiggler


Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | LPC2000 | WOrking of RTC in LPC2148

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

WOrking of RTC in LPC2148 - raju_nem - Oct 28 8:20:11 2009



HI

i need to use rtc of lpc2148.For every sec, i need to send the time to Hyperterminal.I am using gcc compiler.i searched sample codes.Those are

not working.Any one worked on RTC of lpc2148? help me ,thanks in advance.

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )


Re: WOrking of RTC in LPC2148 - raju_nem - Oct 28 15:51:16 2009


OK leave the interrupt section.Basic (only) rtc functions i am posting here=
.plz help whether any thing wrong in the code?thanks in advance.

#include "LPC2148.h"
#include "UART0.h"
#include "pll.h"
#define PCLK 60000000
#define T0_PCLK_DIV 3
#define GERMAN

#ifdef GERMAN
//char* const gWeekDays[] =3D {"Mo","Di","Mi","Do","Fr","Sa","So"};
char* const gWeekDays[] =3D {"Mo","Tu","We","Th","Fr","Sa","Su"};
#else
char* const gWeekDays[] =3D {"Mo","Tu","We","Th","Fr","Sa","So"};
#endif
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned long long uint64_t;
typedef signed long long int64_t;

struct tTimestamp {
uint16_t y;
uint8_t mo;
uint8_t d;
uint8_t h;
uint8_t mi;
uint8_t s;
uint8_t dow;
};

void def_isr(void)
{
Tx_string("Unknown interrupt");
VICVECTADDR =3D 0x00000000; //Dummy write to signal end of interrup=
t
}
void intilalize_timer(void)
{
=20=20
T0TCR =3D 0x02; // reset & disable timer 0
T0PR =3D 2; // set the prescale divider
T0MCR =3D 0; // disable match registers
T0EMR =3D 0; // disable external match register
T0TCR =3D 0x01; // enable timer 0
// sysTICs =3D 0;///////
}

static void sysInit(void)
{
PLL_init(); // intialization of PLL and PCLK IS 60mhz
=20=20
VICINTENCLEAR =3D 0xFFFFFFFF; // clear all interrupts
VICINTSELECT =3D 0x00000000; // clear all FIQ selections
VICDEFVECTADDR =3D (uint32_t)def_isr; // point unvectored IRQs to res=
et()

intilalize_timer(); // initialize the system timer
}

void RTC_InitHardware(void)
{
AMR =3D 0; //alarm mask register to control the alarm registers
CIIR =3D 0; //count increment register tells the when interrupt will be=
generated when count increments
PREINT =3D((PCLK/32768)-1));
PREFRAC =3D(( PCLK) − ((PREINT + 1) =D7 32768)); //prescaler fractio=
n register PREFRAC =3D PCLK − ((PREINT + 1) =D7 32768)
=09
CCR =3D 0x02; //Reset value in Clock Tick Counter (CTC)
CCR =3D 0x01; // disabale CTC-Reset and enable clock with CLKEN=20
}
void RTC_SetDOW(uint8_t dow)
{
DOW =3D (uint32_t)dow;
}

void RTC_SetDate(uint8_t d, uint8_t mo, uint16_t y)
{
DOM =3D (uint32_t)d;
MONTH =3D (uint32_t)mo;
YEAR =3D (uint32_t)y;
}

void RTC_SetTime(uint8_t h, uint8_t m, uint8_t s)
{
CCR =3D 0x20;// Reset value in Clock Tick Counter (CTC) and disable clock=
=20
SEC =3D (uint32_t)s;
MIN =3D (uint32_t)m;
HOUR=3D (uint32_t)h;
CCR =3D 0x01; //re-enable RTC=20
}
void RTC_GetTime(struct tTimestamp *ts)
{
ts->s =3D (uint8_t)SEC;
ts->mi =3D (uint8_t)MIN;
ts->h =3D (uint8_t)HOUR;
ts->d =3D (uint8_t)DOM;
ts->mo =3D (uint8_t)MONTH;
ts->y =3D (uint16_t)YEAR;
ts->dow=3D (uint8_t)DOW;
}
static void show_clock(uint8_t second_mode)
{
struct tTimestamp ts;
char s[4];
=09
=09
s[2]=3D'\0';
RTC_GetTime(&ts);
=09
=09
}

int main()
{

=20
char work_string[40];
=09
uint8_t oldSecond=3D0xff, actSecond;

sysInit();

PINSEL0 =3D 0x00000005;
InitUart0();
Tx_string("WELCOME TO SERIAL PORT DEMO\n");
RTC_InitHardware();
RTC_SetDOW(2);
RTC_SetDate(29,10,2009);
RTC_SetTime(00,00,30);=20
for(;;)
{
actSecond =3D (uint8_t)SEC;
if(actSecond !=3D oldSecond)
{
oldSecond =3D actSecond;
work_string[0] =3D '\0';
show_clock(2);

}
}
}

uart and PLL code is fine.Problem in above code only.Help me who have worke=
d on RTC.

--- In l...@yahoogroups.com, "raju_nem" wrote:
>
>=20
>=20
> HI=20
>=20
> i need to use rtc of lpc2148.For every sec, i need to send the time to H=
yperterminal.I am using gcc compiler.i searched sample codes.Those are
>=20
> not working.Any one worked on RTC of lpc2148? help me ,thanks in advance.
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: Re: WOrking of RTC in LPC2148 - leon Heller - Oct 28 16:55:38 2009

Here's a very simple test program of mine:

/*
** RTC.c
** Test program for LPC2148 RTC
*/

// Include files

#include
#include
// #defines

#define LF 0x0A
#define CR 0x0D

// Function prototypes

int main(void);
void Initialise(void);

//----------------------- main ----------------------------//

int main(void)
{
Initialise(); // initialisation stuff

// LED off
IO0SET = IO0SET |= (1 << 8);

SEC = MIN = HOUR = 0;
T0IR = 0x10;
T0IR |= 0x01;
asm("nop");

while(1)
{
debug_printf("\n%d %d %d", HOUR, MIN, SEC);

asm("nop");

}

}

//-------------------- initialisation stuff --------------------//

void Initialise(void)
{
// initialise PLL

PLL0CFG=0x24; // Cclk = 60Mhz
PLL0CON=0x01;
PLL0FEED=0xAA;
PLL0FEED=0x55;
while(!(PLL0STAT & 0x0400))
;
PLL0CON=0x3;
PLL0FEED=0xAA;
PLL0FEED=0x55;

// initialise MAM and VPB

MAMTIM=0x3; // 3 cycles to read from FLASH
MAMCR=0x2;
APBDIV=0x02; // Pclk = 30MHz

// initialise RTC

ILR = 3; // Disable 32768 kHz interrupt

CCR = 0x11; // enable time counters, 32768 kHz oscillator

// initialise GPIOs

IO0DIR = IO0DIR | 1 << 8; //P0.8 output
}

Leon

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: WOrking of RTC in LPC2148 - raju_nem - Oct 29 1:02:37 2009


Hi leon Heller,

is sample code working fine?

For interfacing RTC,Memory accelaration module(MAM) is compulsory?

--- In l...@yahoogroups.com, "leon Heller" wrote:
>
> Here's a very simple test program of mine:
>
> /*
> ** RTC.c
> ** Test program for LPC2148 RTC
> */
>
> // Include files
>
> #include
> #include
> // #defines
>
> #define LF 0x0A
> #define CR 0x0D
>
> // Function prototypes
>
> int main(void);
> void Initialise(void);
>
> //----------------------- main ----------------------------//
>
> int main(void)
> {
> Initialise(); // initialisation stuff
>
> // LED off
> IO0SET = IO0SET |= (1 << 8);
>
> SEC = MIN = HOUR = 0;
> T0IR = 0x10;
> T0IR |= 0x01;
> asm("nop");
>
> while(1)
> {
> debug_printf("\n%d %d %d", HOUR, MIN, SEC);
>
> asm("nop");
>
> }
>
> }
>
> //-------------------- initialisation stuff --------------------//
>
> void Initialise(void)
> {
> // initialise PLL
>
> PLL0CFG=0x24; // Cclk = 60Mhz
> PLL0CON=0x01;
> PLL0FEED=0xAA;
> PLL0FEED=0x55;
> while(!(PLL0STAT & 0x0400))
> ;
> PLL0CON=0x3;
> PLL0FEED=0xAA;
> PLL0FEED=0x55;
>
> // initialise MAM and VPB
>
> MAMTIM=0x3; // 3 cycles to read from FLASH
> MAMCR=0x2;
> APBDIV=0x02; // Pclk = 30MHz
>
> // initialise RTC
>
> ILR = 3; // Disable 32768 kHz interrupt
>
> CCR = 0x11; // enable time counters, 32768 kHz oscillator
>
> // initialise GPIOs
>
> IO0DIR = IO0DIR | 1 << 8; //P0.8 output
> }
>
> Leon
>

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: WOrking of RTC in LPC2148 - raju_nem - Oct 29 6:02:06 2009

there is problem in this code- it is in finite loop by printing "rtc init h=
ardware is over2" i am using the messages for debugging puprpose.what is wr=
ong in this RTC code? help thanks in advance

#include "LPC2148.h"
#include "UART0.h"
#include "pll.h"
#define PCLK 60000000
#define T0_PCLK_DIV 3
#define NOW 1792

typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned long long uint64_t;
typedef signed long long int64_t;

struct tTimestamp {
uint16_t y;
uint8_t mo;
uint8_t d;
uint8_t h;
uint8_t mi;
uint8_t s;
uint8_t dow;
};

void def_isr(void)
{
Tx_string("Unknown interrupt");
VICVECTADDR =3D 0x00000000; //Dummy write to signal end of interrup=
t
}
void intilalize_timer(void)
{
=20=20
T0TCR =3D 0x02; // reset & disable timer 0
T0PR =3D 2; // set the prescale divider
T0MCR =3D 0; // disable match registers
T0EMR =3D 0; // disable external match register
T0TCR =3D 0x01; // enable timer 0
// sysTICs =3D 0;///////
}

static void sysInit(void)
{
PLL_init(); // intialization of PLL and PCLK IS 60mhz
=20=20
VICINTENCLEAR =3D 0xFFFFFFFF; // clear all interrupts
VICINTSELECT =3D 0x00000000; // clear all FIQ selections
VICDEFVECTADDR =3D (uint32_t)def_isr; // point unvectored IRQs to res=
et()

intilalize_timer(); // initialize the system timer
}

void RTC_InitHardware(void)
{
AMR =3D 0; //alarm mask register to control the alarm registers
CIIR =3D 0; //count increment register tells the when interrupt will be=
generated when count increments
PREINT =3D1830;
PREFRAC =3DNOW; //prescaler fraction register PREFRAC =3D PCLK - ((PREINT =
+ 1) =C3=97 32768)
=09
CCR =3D 0x02; //Reset value in Clock Tick Counter (CTC)
CCR =3D 0x01; // disabale CTC-Reset and enable clock with CLKEN=20
}
void RTC_SetDOW(uint8_t dow)
{
DOW =3D (uint32_t)dow;
}

void RTC_SetDate(uint8_t d, uint8_t mo, uint16_t y)
{
DOM =3D (uint32_t)d;
MONTH =3D (uint32_t)mo;
YEAR =3D (uint32_t)y;
}

void RTC_SetTime(uint8_t h, uint8_t m, uint8_t s)
{
CCR =3D 0x20;// Reset value in Clock Tick Counter (CTC) and disable clock=
=20
SEC =3D (uint32_t)s;
MIN =3D (uint32_t)m;
HOUR=3D (uint32_t)h;
CCR =3D 0x01; //re-enable RTC=20
}
void RTC_GetTime(struct tTimestamp *ts)
{
ts->s =3D (uint8_t)SEC;
ts->mi =3D (uint8_t)MIN;
ts->h =3D (uint8_t)HOUR;
ts->d =3D (uint8_t)DOM;
ts->mo =3D (uint8_t)MONTH;
ts->y =3D (uint16_t)YEAR;
ts->dow=3D (uint8_t)DOW;
Tx_string("rtc init hardware is over4\n");
Tx_char(ts->s);
Tx_char(ts->mi);
Tx_string("rtc init hardware is over5\n");
}
static void show_clock(uint8_t second_mode)
{
struct tTimestamp ts;
char s[4];
=09
=09
s[2]=3D'\0';
RTC_GetTime(&ts);
=09
=09
}

int main()
{

=20
char work_string[40];
=09
uint8_t oldSecond=3D0xff, actSecond;

sysInit();

PINSEL0 =3D 0x00000005;
InitUart0();
Tx_string("WELCOME TO SERIAL PORT DEMO\n");
RTC_InitHardware();
Tx_string("rtc init hardware is over\n");
RTC_SetDOW(2);
RTC_SetDate(29,10,2009);
RTC_SetTime(14,52,30);
Tx_string("rtc init hardware is over1\n");
for(;;)
{
actSecond =3D (uint8_t)SEC;
Tx_string("rtc init hardware is over2\n");
if(actSecond !=3D oldSecond)
{
oldSecond =3D actSecond;
work_string[0] =3D '\0';
Tx_string("rtc init hardware is over3\n");
show_clock(2);

}
}
}

Tx_char and Tx_string are functions to display the messages or character.

what are the steps to follow while use of INTERNAL rtc of lpc2148?
help me.

--- In l...@yahoogroups.com, "raju_nem" wrote:
>
>=20
> Hi leon Heller,
>=20
> is sample code working fine?
>=20
> For interfacing RTC,Memory accelaration module(MAM) is compulsory?
>=20
> --- In l...@yahoogroups.com, "leon Heller" wrote:
> >
> > Here's a very simple test program of mine:
> >=20
> > /*
> > ** RTC.c
> > ** Test program for LPC2148 RTC
> > */
> >=20
> > // Include files
> >=20
> > #include
> > #include
> >=20
> >=20
> > // #defines=20=20
> >=20
> > #define LF 0x0A
> > #define CR 0x0D
> >=20
> > // Function prototypes
> >=20
> > int main(void);
> > void Initialise(void);
> >=20
> >=20
> >=20
> > //----------------------- main ----------------------------//
> >=20
> > int main(void)
> > {
> > Initialise(); // initialisation stuff
> >=20
> > // LED off
> > IO0SET =3D IO0SET |=3D (1 << 8);
> >=20
> > SEC =3D MIN =3D HOUR =3D 0;
> >=20
> >=20
> > T0IR =3D 0x10;
> > T0IR |=3D 0x01;
> >=20
> >=20
> > asm("nop");
> >=20
> > while(1)
> > {
> > debug_printf("\n%d %d %d", HOUR, MIN, SEC);
> >=20=20=20=20=20
> > asm("nop");
> >=20
> > }
> >=20
> > }
> >=20
> >=20
> >=20
> > //-------------------- initialisation stuff --------------------//=20
> >=20
> > void Initialise(void)
> > {
> > // initialise PLL
> >=20
> > PLL0CFG=3D0x24; // Cclk =3D 60Mhz
> > PLL0CON=3D0x01;
> > PLL0FEED=3D0xAA;
> > PLL0FEED=3D0x55;
> > while(!(PLL0STAT & 0x0400))
> > ;
> > PLL0CON=3D0x3;
> > PLL0FEED=3D0xAA;
> > PLL0FEED=3D0x55;
> >=20
> > // initialise MAM and VPB
> >=20
> > MAMTIM=3D0x3; // 3 cycles to read from FLASH
> > MAMCR=3D0x2;
> > APBDIV=3D0x02; // Pclk =3D 30MHz
> >=20
> > // initialise RTC
> >=20
> > ILR =3D 3; // Disable 32768 kHz interrupt
> >=20
> > CCR =3D 0x11; // enable time counters, 32768 kHz oscillator
> >=20=20=20
> > // initialise GPIOs
> >=20
> > IO0DIR =3D IO0DIR | 1 << 8; //P0.8 output
> > }
> >=20
> > Leon
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

RE: Re: WOrking of RTC in LPC2148 - Toby Harris - Oct 29 6:20:57 2009

It would be much easier to use the RTC's CIIR register (see LPC2148 user ma=
nual).
=20
Then Google for a suitable example eg "LPC2148 CIIR"
=20
Remember "Google" is your best friend!
=20
________________________________

From: l...@yahoogroups.com [mailto:l...@yahoogroups.com] On Behalf Of=
raju_nem
Sent: 29 October 2009 10:01
To: l...@yahoogroups.com
Subject: [lpc2000] Re: WOrking of RTC in LPC2148
=20=20

there is problem in this code- it is in finite loop by printing "rtc init h=
ardware is over2" i am using the messages for debugging puprpose.what is wr=
ong in this RTC code? help thanks in advance

#include "LPC2148.h"
#include "UART0.h"
#include "pll.h"

#define PCLK 60000000
#define T0_PCLK_DIV 3
#define NOW 1792

typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned long uint32_t;
typedef signed long int32_t;
typedef unsigned long long uint64_t;
typedef signed long long int64_t;

struct tTimestamp {
uint16_t y;
uint8_t mo;
uint8_t d;
uint8_t h;
uint8_t mi;
uint8_t s;
uint8_t dow;
};

void def_isr(void)
{
Tx_string("Unknown interrupt");
VICVECTADDR =3D 0x00000000; //Dummy write to signal end of interrupt
}
void intilalize_timer(void)
{

T0TCR =3D 0x02; // reset & disable timer 0
T0PR =3D 2; // set the prescale divider
T0MCR =3D 0; // disable match registers
T0EMR =3D 0; // disable external match register
T0TCR =3D 0x01; // enable timer 0
// sysTICs =3D 0;///////
}

static void sysInit(void)
{
PLL_init(); // intialization of PLL and PCLK IS 60mhz

VICINTENCLEAR =3D 0xFFFFFFFF; // clear all interrupts
VICINTSELECT =3D 0x00000000; // clear all FIQ selections
VICDEFVECTADDR =3D (uint32_t)def_isr; // point unvectored IRQs to reset()

intilalize_timer(); // initialize the system timer
}

void RTC_InitHardware(void)
{
AMR =3D 0; //alarm mask register to control the alarm registers
CIIR =3D 0; //count increment register tells the when interrupt will be gen=
erated when count increments
PREINT =3D1830;
PREFRAC =3DNOW; //prescaler fraction register PREFRAC =3D PCLK - ((PREINT +=
1) =C3- 32768)

CCR =3D 0x02; //Reset value in Clock Tick Counter (CTC)
CCR =3D 0x01; // disabale CTC-Reset and enable clock with CLKEN=20
}
void RTC_SetDOW(uint8_t dow)
{
DOW =3D (uint32_t)dow;
}

void RTC_SetDate(uint8_t d, uint8_t mo, uint16_t y)
{
DOM =3D (uint32_t)d;
MONTH =3D (uint32_t)mo;
YEAR =3D (uint32_t)y;
}

void RTC_SetTime(uint8_t h, uint8_t m, uint8_t s)
{
CCR =3D 0x20;// Reset value in Clock Tick Counter (CTC) and disable clock=20
SEC =3D (uint32_t)s;
MIN =3D (uint32_t)m;
HOUR=3D (uint32_t)h;
CCR =3D 0x01; //re-enable RTC=20
}
void RTC_GetTime(struct tTimestamp *ts)
{
ts->s =3D (uint8_t)SEC;
ts->mi =3D (uint8_t)MIN;
ts->h =3D (uint8_t)HOUR;
ts->d =3D (uint8_t)DOM;
ts->mo =3D (uint8_t)MONTH;
ts->y =3D (uint16_t)YEAR;
ts->dow=3D (uint8_t)DOW;
Tx_string("rtc init hardware is over4\n");
Tx_char(ts->s);
Tx_char(ts->mi);
Tx_string("rtc init hardware is over5\n");
}
static void show_clock(uint8_t second_mode)
{
struct tTimestamp ts;
char s[4];
s[2]=3D'\0';
RTC_GetTime(&ts);
}

int main()
{

char work_string[40];

uint8_t oldSecond=3D0xff, actSecond;

sysInit();

PINSEL0 =3D 0x00000005;
InitUart0();
Tx_string("WELCOME TO SERIAL PORT DEMO\n");
RTC_InitHardware();
Tx_string("rtc init hardware is over\n");
RTC_SetDOW(2);
RTC_SetDate(29,10,2009);
RTC_SetTime(14,52,30);
Tx_string("rtc init hardware is over1\n");
for(;;)
{
actSecond =3D (uint8_t)SEC;
Tx_string("rtc init hardware is over2\n");
if(actSecond !=3D oldSecond)
{
oldSecond =3D actSecond;
work_string[0] =3D '\0';
Tx_string("rtc init hardware is over3\n");
show_clock(2);

}
}
}

Tx_char and Tx_string are functions to display the messages or character.

what are the steps to follow while use of INTERNAL rtc of lpc2148?
help me.

--- In l...@yahoogroups.com , "raju_n=
em" wrote:
>
>=20
> Hi leon Heller,
>=20
> is sample code working fine?
>=20
> For interfacing RTC,Memory accelaration module(MAM) is compulsory?
>=20
> --- In l...@yahoogroups.com , "leon=
Heller" wrote:
> >
> > Here's a very simple test program of mine:
> >=20
> > /*
> > ** RTC.c
> > ** Test program for LPC2148 RTC
> > */
> >=20
> > // Include files
> >=20
> > #include
> > #include
> >=20
> >=20
> > // #defines=20
> >=20
> > #define LF 0x0A
> > #define CR 0x0D
> >=20
> > // Function prototypes
> >=20
> > int main(void);
> > void Initialise(void);
> >=20
> >=20
> >=20
> > //----------------------- main ----------------------------//
> >=20
> > int main(void)
> > {
> > Initialise(); // initialisation stuff
> >=20
> > // LED off
> > IO0SET =3D IO0SET |=3D (1 << 8);
> >=20
> > SEC =3D MIN =3D HOUR =3D 0;
> >=20
> >=20
> > T0IR =3D 0x10;
> > T0IR |=3D 0x01;
> >=20
> >=20
> > asm("nop");
> >=20
> > while(1)
> > {
> > debug_printf("\n%d %d %d", HOUR, MIN, SEC);
> >=20
> > asm("nop");
> >=20
> > }
> >=20
> > }
> >=20
> >=20
> >=20
> > //-------------------- initialisation stuff --------------------//=20
> >=20
> > void Initialise(void)
> > {
> > // initialise PLL
> >=20
> > PLL0CFG=3D0x24; // Cclk =3D 60Mhz
> > PLL0CON=3D0x01;
> > PLL0FEED=3D0xAA;
> > PLL0FEED=3D0x55;
> > while(!(PLL0STAT & 0x0400))
> > ;
> > PLL0CON=3D0x3;
> > PLL0FEED=3D0xAA;
> > PLL0FEED=3D0x55;
> >=20
> > // initialise MAM and VPB
> >=20
> > MAMTIM=3D0x3; // 3 cycles to read from FLASH
> > MAMCR=3D0x2;
> > APBDIV=3D0x02; // Pclk =3D 30MHz
> >=20
> > // initialise RTC
> >=20
> > ILR =3D 3; // Disable 32768 kHz interrupt
> >=20
> > CCR =3D 0x11; // enable time counters, 32768 kHz oscillator
> >=20
> > // initialise GPIOs
> >=20
> > IO0DIR =3D IO0DIR | 1 << 8; //P0.8 output
> > }
> >=20
> > Leon
>

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

------------------------------------



(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )

Re: WOrking of RTC in LPC2148 - raju_nem - Oct 30 7:41:17 2009


Thank you,i understood little bit more with u r information.I read the lpc2=
148 RTC manual.I am trying to use the PCLK(peripheral clock) as a clock so=
urce for RTC.
What are the values we need to write in to Prescale inter (PREINT) and pres=
cale fractional register(PREFRAC) registers if i use 60MHZ (PLCK) clock.

from manual i understood that,

PREINT =3D int (PCLK / 32768) =E2=88' 1.

PREFRAC =3D PCLK =E2=88' ((PREINT + 1) =C3=97 32768).
I am using 60MHZ as PCLK then,PREINT =3D((60000000/32768)-1)=3D1830 in hexa=
decimal it is 0x726.
PREFRAC=3D(60000000) =E2=88' ((1831 + 1) =C3=97 32768)=
.

is this correct? if wrong,plz help me thank in advance.
One more doubt is=20
void Initialize_RTC()
{

CCR=3D0x2; /* Reset the clock */

ILR=3D0x3; /* Clear the Interrupt Location Register */

CIIR=3D0x01;

HOUR=3D0x0;

SEC=3D0x0;

MIN=3D0x0;

PREINT =3D 0x726;; some doubt on this?

PREFRAC =3D 0x700; some doubt on this?

VICINTSELECT=3D0x00000000;

VICVECTADDR0=3D(unsigned long )readRTC_irq;

VICVECTCNTL0=3D0x2d;

VICINTENABLE =3D0x2000;=20=20=20

}

THE last line VICINTENABLE =3D0x2000; is not excuting.i tried.what may be=
problem here.Help me thanks in advance.
--- In l...@yahoogroups.com, "Toby Harris" wrote:
>
> It would be much easier to use the RTC's CIIR register (see LPC2148 user =
manual).
>=20=20
> Then Google for a suitable example eg "LPC2148 CIIR"
>=20=20
> Remember "Google" is your best friend!
>=20=20
> ________________________________
>=20
> From: l...@yahoogroups.com [mailto:l...@yahoogroups.com] On Behalf =
Of raju_nem
> Sent: 29 October 2009 10:01
> To: l...@yahoogroups.com
> Subject: [lpc2000] Re: WOrking of RTC in LPC2148
>=20
>=20
>=20=20=20
>=20
> there is problem in this code- it is in finite loop by printing "rtc init=
hardware is over2" i am using the messages for debugging puprpose.what is =
wrong in this RTC code? help thanks in advance
>=20
> #include "LPC2148.h"
> #include "UART0.h"
> #include "pll.h"
>=20
> #define PCLK 60000000
> #define T0_PCLK_DIV 3
> #define NOW 1792
>=20
> typedef unsigned char uint8_t;
> typedef signed char int8_t;
> typedef unsigned short uint16_t;
> typedef signed short int16_t;
> typedef unsigned long uint32_t;
> typedef signed long int32_t;
> typedef unsigned long long uint64_t;
> typedef signed long long int64_t;
>=20
> struct tTimestamp {
> uint16_t y;
> uint8_t mo;
> uint8_t d;
> uint8_t h;
> uint8_t mi;
> uint8_t s;
> uint8_t dow;
> };
>=20
> void def_isr(void)
> {
> Tx_string("Unknown interrupt");
> VICVECTADDR =3D 0x00000000; //Dummy write to signal end of interrupt
> }
> void intilalize_timer(void)
> {
>=20
> T0TCR =3D 0x02; // reset & disable timer 0
> T0PR =3D 2; // set the prescale divider
> T0MCR =3D 0; // disable match registers
> T0EMR =3D 0; // disable external match register
> T0TCR =3D 0x01; // enable timer 0
> // sysTICs =3D 0;///////
> }
>=20
> static void sysInit(void)
> {
> PLL_init(); // intialization of PLL and PCLK IS 60mhz
>=20
> VICINTENCLEAR =3D 0xFFFFFFFF; // clear all interrupts
> VICINTSELECT =3D 0x00000000; // clear all FIQ selections
> VICDEFVECTADDR =3D (uint32_t)def_isr; // point unvectored IRQs to reset()
>=20
> intilalize_timer(); // initialize the system timer
> }
>=20
> void RTC_InitHardware(void)
> {
> AMR =3D 0; //alarm mask register to control the alarm registers
> CIIR =3D 0; //count increment register tells the when interrupt will be g=
enerated when count increments
> PREINT =3D1830;
> PREFRAC =3DNOW; //prescaler fraction register PREFRAC =3D PCLK - ((PREINT=
+ 1) =EF=BF=BD- 32768)
>=20
> CCR =3D 0x02; //Reset value in Clock Tick Counter (CTC)
> CCR =3D 0x01; // disabale CTC-Reset and enable clock with CLKEN=20
> }
> void RTC_SetDOW(uint8_t dow)
> {
> DOW =3D (uint32_t)dow;
> }
>=20
> void RTC_SetDate(uint8_t d, uint8_t mo, uint16_t y)
> {
> DOM =3D (uint32_t)d;
> MONTH =3D (uint32_t)mo;
> YEAR =3D (uint32_t)y;
> }
>=20
> void RTC_SetTime(uint8_t h, uint8_t m, uint8_t s)
> {
> CCR =3D 0x20;// Reset value in Clock Tick Counter (CTC) and disable clock=
=20
> SEC =3D (uint32_t)s;
> MIN =3D (uint32_t)m;
> HOUR=3D (uint32_t)h;
> CCR =3D 0x01; //re-enable RTC=20
> }
> void RTC_GetTime(struct tTimestamp *ts)
> {
> ts->s =3D (uint8_t)SEC;
> ts->mi =3D (uint8_t)MIN;
> ts->h =3D (uint8_t)HOUR;
> ts->d =3D (uint8_t)DOM;
> ts->mo =3D (uint8_t)MONTH;
> ts->y =3D (uint16_t)YEAR;
> ts->dow=3D (uint8_t)DOW;
> Tx_string("rtc init hardware is over4\n");
> Tx_char(ts->s);
> Tx_char(ts->mi);
> Tx_string("rtc init hardware is over5\n");
> }
> static void show_clock(uint8_t second_mode)
> {
> struct tTimestamp ts;
> char s[4];
>=20
>=20
> s[2]=3D'\0';
> RTC_GetTime(&ts);
>=20
>=20
> }
>=20
> int main()
> {
>=20
> char work_string[40];
>=20
> uint8_t oldSecond=3D0xff, actSecond;
>=20
> sysInit();
>=20
> PINSEL0 =3D 0x00000005;
> InitUart0();
> Tx_string("WELCOME TO SERIAL PORT DEMO\n");
> RTC_InitHardware();
> Tx_string("rtc init hardware is over\n");
> RTC_SetDOW(2);
> RTC_SetDate(29,10,2009);
> RTC_SetTime(14,52,30);
> Tx_string("rtc init hardware is over1\n");
> for(;;)
> {
> actSecond =3D (uint8_t)SEC;
> Tx_string("rtc init hardware is over2\n");
> if(actSecond !=3D oldSecond)
> {
> oldSecond =3D actSecond;
> work_string[0] =3D '\0';
> Tx_string("rtc init hardware is over3\n");
> show_clock(2);
>=20
> }
> }
> }
>=20
> Tx_char and Tx_string are functions to display the messages or character.
>=20
> what are the steps to follow while use of INTERNAL rtc of lpc2148?
> help me.
>=20
> --- In l...@yahoogroups.com , "raju=
_nem" wrote:
> >
> >=20
> > Hi leon Heller,
> >=20
> > is sample code working fine?
> >=20
> > For interfacing RTC,Memory accelaration module(MAM) is compulsory?
> >=20
> > --- In l...@yahoogroups.com , "le=
on Heller" wrote:
> > >
> > > Here's a very simple test program of mine:
> > >=20
> > > /*
> > > ** RTC.c
> > > ** Test program for LPC2148 RTC
> > > */
> > >=20
> > > // Include files
> > >=20
> > > #include
> > > #include
> > >=20
> > >=20
> > > // #defines=20
> > >=20
> > > #define LF 0x0A
> > > #define CR 0x0D
> > >=20
> > > // Function prototypes
> > >=20
> > > int main(void);
> > > void Initialise(void);
> > >=20
> > >=20
> > >=20
> > > //----------------------- main ----------------------------//
> > >=20
> > > int main(void)
> > > {
> > > Initialise(); // initialisation stuff
> > >=20
> > > // LED off
> > > IO0SET =3D IO0SET |=3D (1 << 8);
> > >=20
> > > SEC =3D MIN =3D HOUR =3D 0;
> > >=20
> > >=20
> > > T0IR =3D 0x10;
> > > T0IR |=3D 0x01;
> > >=20
> > >=20
> > > asm("nop");
> > >=20
> > > while(1)
> > > {
> > > debug_printf("\n%d %d %d", HOUR, MIN, SEC);
> > >=20
> > > asm("nop");
> > >=20
> > > }
> > >=20
> > > }
> > >=20
> > >=20
> > >=20
> > > //-------------------- initialisation stuff --------------------//=20
> > >=20
> > > void Initialise(void)
> > > {
> > > // initialise PLL
> > >=20
> > > PLL0CFG=3D0x24; // Cclk =3D 60Mhz
> > > PLL0CON=3D0x01;
> > > PLL0FEED=3D0xAA;
> > > PLL0FEED=3D0x55;
> > > while(!(PLL0STAT & 0x0400))
> > > ;
> > > PLL0CON=3D0x3;
> > > PLL0FEED=3D0xAA;
> > > PLL0FEED=3D0x55;
> > >=20
> > > // initialise MAM and VPB
> > >=20
> > > MAMTIM=3D0x3; // 3 cycles to read from FLASH
> > > MAMCR=3D0x2;
> > > APBDIV=3D0x02; // Pclk =3D 30MHz
> > >=20
> > > // initialise RTC
> > >=20
> > > ILR =3D 3; // Disable 32768 kHz interrupt
> > >=20
> > > CCR =3D 0x11; // enable time counters, 32768 kHz oscillator
> > >=20
> > > // initialise GPIOs
> > >=20
> > > IO0DIR =3D IO0DIR | 1 << 8; //P0.8 output
> > > }
> > >=20
> > > Leon
> > >
> >
>=20
>=20
>=20
>=20
>=20
>=20
> [Non-text portions of this message have been removed]
>

------------------------------------

______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.


(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )