UART0 and RTC

Started by liem...@yahoo.com July 25, 2007
I am a newbie in ARM. I make a digital clock project with internal RTC and send with uart0. I have been tested the UART0 without RTC initialitation and works well. but when I init RTC and RTC interrupt UART0 can't work. This is my source code. I use Keil for the compler.

Thank you.

#include
#include

unsigned char jam,menit,detik;

void update (unsigned char a,unsigned char b,unsigned char c)
{
putchar(a/10+0x30);
putchar(a%10+0x30);
putchar(':');
putchar(b/10+0x30);
putchar(b%10+0x30);
putchar(':');
putchar(c/10+0x30);
putchar(c%10+0x30);
putchar(0x0D);
}

void RTCIrq (void) __irq
{
ILR=1;
detik=SEC;
menit=MIN;
jam=HOUR;
update(jam,menit,detik);
VICVectAddr=0;
}

void LPC2104_Init(void)
{
//setting RTC
ILR=1;
CIIR=1;
SEC=0;
MIN=0;
HOUR=0;
PREINT1; //29 for proteus
PREFRAC384; //16960 for proteus
CCR=1;

//vector interrupt controller
VICVectAddr0 = (unsigned int) &RTCIrq;
VICVectCntl0 = 0x2D;
VICIntEnable|= 0x2000;

//setting GPIO for UART0 without FIFO
//DLM and DLH = Fpclk/(9600*16) $
PINSEL0|=0x00000005;
PINSEL1|=0x00000000;
U0FCR =0x00;
U0LCR =0x83;
U0DLL $; //0D for proteus
U0DLM =0;
U0LCR =0x03;
}

int sendchar (unsigned char kar)
{
U0THR=kar;
while(!(U0LSR & (1<<6)));
return kar;
}

int getkey (void)
{
while (!(U0LSR & 0x01));
return (U0RBR);
}

int main (void)
{
LPC2104_Init();
detik=SEC;
menit=MIN;
jam=HOUR;

puts("Digital Clock\r");
update(jam,menit,detik);

while(1)
{

}
}

An Engineer's Guide to the LPC2100 Series