pawan kumar
Member level 4
Greetings,
I am a newbie and this is my first post in edaboard.
I am trying to receive data from GPS module to LPC2148 through UART 1 and send the same to PC-hyperterminal through UART0. both take place at 9600 baud. Please see through my code.The hyperterminal is blank. I know I am wrong, unable to find out where. help me out.
Or if i am making any other mistake in the very fundamental approach of receiving data, please guide me. I have tested each function individually.
Thanks in advance
Pawan
I am a newbie and this is my first post in edaboard.
I am trying to receive data from GPS module to LPC2148 through UART 1 and send the same to PC-hyperterminal through UART0. both take place at 9600 baud. Please see through my code.The hyperterminal is blank. I know I am wrong, unable to find out where. help me out.
Or if i am making any other mistake in the very fundamental approach of receiving data, please guide me. I have tested each function individually.
Code:
#include<lpc214x.h>
void inituart1() //initializes both UARTS at 9600 baud
{
U1LCR=0x83;
U1DLL=0x61;
U1DLM=0x00;
U1LCR=0x03;
U0LCR=0x83;
U0DLL=0x61;
U0DLM=0x00;
U0LCR=0x03;
}
void send(unsigned char a) //sends a byte through U0
{
U0THR=a;
while(U0LSR!=0x60);
}
void senduart1(unsigned char a) //sends a byte through U1
{
U1THR=a;
while(U1LSR!=0x60);
}
unsigned char recuart1() // recieves a byte from U1
{
unsigned char p;
while ((U1LSR&0x01)!=1);
p=U1RBR;
return p;
}
unsigned char rec() // recieves a byte from U0
{
unsigned char p;
while ((U0LSR&0x01)!=1);
p=U0RBR;
return p;
}
int main()
{
PINSEL0=0x00050005; //initialized U0 and U1 as UART and not GPIO
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
inituart1();
while(1)
{
send(recuart1());
}
}
Thanks in advance
Pawan