lpc2148

Hello All,

i’m struggling to receive data from gps receiver module to terminal window using lpc2148 in keiluvision 4 .i’m getting some junk data on terminal window.my baud rate is correct,i tried so many ways but i couldn’t catch the error.Any one give some idea to solve this issue.

naz:
Hello All,

i’m struggling to receive data from gps receiver module to terminal window using lpc2148 in keiluvision 4 .i’m getting some junk data on terminal window.my baud rate is correct,i tried so many ways but i couldn’t catch the error.Any one give some idea to solve this issue.

well, you’ve given us no specific symptoms. I have received 4800baud NMEA sentences on an LPC2106. Do you have the serial data voltage levels and data polarity correct?

Your baud rate might be correct, but are your clocks set up correctly?

Can you use a different device to input correct data to the processor (like a computer)?

Can you post any code from your MCU setup routines?

Transmit ‘U’ continuously and use a scope to check the baud rate.

Leon

this is the code which i have tried.could u please tell where i’m doing the mistake

#include<LPC214x.h>

#include<stdio.h>



void led(int);

void wait(void);



void serial(void);

char sendchar(char ch);

char recechar(void);



void __irq FIQ_Handler(void);

int main()

{

int ch;

IODIR1=0x00FF0000;

serial();

led(16); 

EXTMODE |=0x02;//level sensitivity for EINT1 

EXTPOLAR |=0x02;//polartiy for EINT1

PINSEL0|=0x20000000; //GPIO0.14,EINT1

EXTINT =0x00000002;	 //clear EINT flag register	

VICIntEnable=0x00008000;

VICIntEnable=0x00008000; //enable interrupt 15

while(1)

{

recechar();

led(17);

ch=U1RBR;

sendchar(ch);

led(18); 

}

}

void serial() 

{

PINSEL0=0xFFF0FFFF;	//clear uart1

PINSEL0|=0x00050000;//TX,RX of uart1 

U1LCR =0x83;//8bit,no parity,1stop bit,enable DLAB

U1DLM =0x01;

U1DLL=0x87;

U1LCR&=0x7F;   //disable DLAB

U1IER = 0x07;	//enable interrrupt

}

char sendchar(char ch)

{

if(ch=='\n')

 { 

  	while(!(U1LSR&0x20));

	U1THR=0x0D;

 }

while(!(U1LSR&0x20));

return(U1THR); 

}

char recechar()

{



while(!(U1LSR&0x01));

if(U1RBR=='

[/quote])

led(23);

return(U1RBR);

}

void led(int n)

{

IOSET1|=1<<n;

wait();

IOCLR1|=1<<n;

wait();

}

void wait()

{

int i;

for(i=0;i<8000000;i++);

}

void __irq FIQ_Handler()

{

EXTINT&=0x00000002; //disable interrupt.

}


[/quote]

Here is some UART code I use:

//------------------------ UART1 ISR ------------------------//
static void uart1ISR(void)
{
  /* Read IIR to clear interrupt and find out the cause */
  unsigned iir = U1IIR;

  /* Handle UART1 interrupt */
  switch ((iir >> 1) & 0x7)
    {
      case 1:
        /* THRE interrupt */
        break;
      case 2:
        /* RDA interrupt */
        do
          {
          uint16_t temp;

          // calc next insert index & store character
          temp = (uart1_rx_insert_idx + 1) % UART1_RX_BUFFER_SIZE;
          uart1_rx_buffer[uart1_rx_insert_idx] = U1RBR;

          // check for more room in queue
          if (temp != uart1_rx_extract_idx)
            uart1_rx_insert_idx = temp; // update insert index
          }
        while (U1LSR & 0x01);

        break;
      case 3:
        /* RLS interrupt */
        break;
      case 6:
        /* CTI interrupt */
        break;
   }
}

/* Description:  
 *    This function gets a character from the UART1 receive queue
 *
 * Calling Sequence: 
 *    void
 *
 * Returns:
 *    character on success, -1 if no character is available
 *
 *****************************************************************************/
int uart1Getch(void)
{
  uint8_t ch;

  if (uart1_rx_insert_idx == uart1_rx_extract_idx) // check if character is available
    return -1;

  ch = uart1_rx_buffer[uart1_rx_extract_idx++]; // get character, bump pointer
  uart1_rx_extract_idx %= UART1_RX_BUFFER_SIZE; // limit the pointer
  return ch;
}


 //put this in the init. function

  // 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;        // MAM functions fully enabled
  APBDIV=0x02;      // Pclk = 30MHz

  // initialise pclk (30 MHz)
  unsigned long pclk = liblpc2000_get_pclk(liblpc2000_get_cclk(OSCILLATOR_CLOCK_FREQUENCY));

 // initialise UART1 (RxD1 P0.9, TxD1 P0.8

  U1LCR = 0x83; // 8 bit, 1 stop bit, no parity, enable DLAB
  U1DLL = 0xC3; // set for 9600 baud
  U1DLM = 0x00;
  U1LCR &= ~0x80; // disable DLAB
  U1FCR = 1;      // enable FIFO
  PINSEL0 = PINSEL0 & ~(0xFFFF << 16) | (0x5555 << 16);

 // initialise Rx circular buffer
  uart1_rx_extract_idx = uart1_rx_insert_idx = 0;

You probably don’t need the circular buffer, so you can remove the relevant code.

Leon