LPC 2148 Serial Communication

Status
Not open for further replies.
Hi.. I've written a code to transmit a character to PC using UART0. But, however, the hyperterminal is blank.
Why is this happening?
My code is as follows:

Code:
#include "LPC214x.h"
void init(void);

int main()
{ int i=0;
init();

while(i<=10){

U1THR='D';
while(!(U1LSR && 0x60));
i++;

}
} 

void init()
{
PINSEL0=0x00050005;
U1FCR=0x07; //enable and clear FIFOs
U1LCR=0x83; //8-N-1, enable divisors
U1DLL=0x62; //9600 baud (9615)
U1DLM=0x00;
U1LCR=0x03; //8-N-1, disable divisors
}
 
But if I modify d same code for UART1 it works fine.. Its only giving a problem with UART0..

Is this happening because I'm using UART0 as ISP port to program my chip? I use flash magic & use the DTR & RTS to control the RST & ISP pins. So is it possible that my port is stuck in ISP mode & is that the reason why its not functioning as a normal UART?

I'm really confused..
 
 
Last edited:
how to use uart interrupt in lpc2148?
how to receive char through interrupt in lpc2148?tell me what is wrong in this code.received char i've to transmit again but it is not working.
#include <lpc214x.h>
void init_UART0(void)
{
VPBDIV=0x01;
PINSEL0|=(1<<0)|(1<<2);
U0LCR=0x83;

/*to set baudrate using formula, load below registers
.....................................................................................................*/
U0DLL=78;
U0FDR=0x28;
U0LCR=0x03;
U0IER=0x01;

VICIntSelect=0x00;//IRQ interrupt
VICVectAddr0=(unsigned long)UART0_isr;//isr assigned to 0th slot
VICVectCntl0=0x26;//vector interrupt enable & UART0 select
VICIntEnable=(1<<6);//enable interrupt

}

void Transmit(unsigned char ch)
{
while(!(U0LSR & 0x20)); //check THO is empty or not
U0THR=ch;
}

void UART0_isr(void)__irq
{
unsigned char p;
p=U0RBR;
Transmit(p);
VICVectAddr0=0x00;//clear address register

}
int main()
{
init_UART0();
while(1);
}
 
it seems that your code is correct . if you are using P0.1 for ISP programing, you must remove the pull up resistor on this pin.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…