lpcware

Reading UART with CMSIS

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by justmakeit on Thu Mar 06 04:04:38 MST 2014
Hello,

I'm using the LPC1766 MCU ant trying to receive data using the UART1.But i'm only receiving 16 bytes. I'm using the CMSIS (v3.2) lib to receive the data.

The interupt handler for UART1:

void UART_Handler(uint8_t uartnr, LPC_UART_TypeDef * UARTx){
  uint8_t tmpc;
  uint32_t rLen;

  while(1){
    // Call UART read function in UART driver
    rLen = UART_Receive(UARTx, &tmpc, 1, NONE_BLOCKING);
    // If data received
    if (rLen){
      if(end_char[uartnr] == tmpc){
         process_post_synch(handler_uart[uartnr], event_newline_uart[uartnr], NULL);
      }
      ringbuf_put(&ringbuf_uart[uartnr], tmpc);
    }
   
    else {// no more data
      break;
    }
  }  
}

volatile void UART1_IRQHandler(void){
UART_Handler(1,(LPC_UART_TypeDef *)LPC_UART1);
}


The init code:



void UART1_P2_Dev_Init(uint32_t Baud_rate, struct process * handler, char LineEndChar)
{
    UART_FIFO_CFG_Type Fifo_CFG;
     
    UART_Dev_Init((LPC_UART_TypeDef *)LPC_UART1, Baud_rate);
   
    PINSEL_CFG_Type pinsel; 
    //TX
    pinsel.Portnum = PINSEL_PORT_2;
    pinsel.Pinnum = PINSEL_PIN_0;
    pinsel.Funcnum = PINSEL_FUNC_2;
    pinsel.Pinmode = PINSEL_PINMODE_TRISTATE;
    pinsel.OpenDrain = PINSEL_PINMODE_OPENDRAIN;
    PINSEL_ConfigPin(&pinsel);

    //RX
    pinsel.Pinnum = PINSEL_PIN_1;
    PINSEL_ConfigPin(&pinsel);
   
    //FIFO
    UART_FIFOConfigStructInit(&Fifo_CFG);
    UART_FIFOConfig((LPC_UART_TypeDef *)LPC_UART1, &Fifo_CFG);
   
    //Interrupt enable
    UART_IntConfig((LPC_UART_TypeDef *)LPC_UART1, UART_INTCFG_RBR, ENABLE);
    NVIC_EnableIRQ(UART1_IRQn);
   
    //Ringbuffer init
    ringbuf_init(&ringbuf_uart[1],(uint8_t *)buffer_uart[1],BUFLEN_UART1);
    end_char[1] = LineEndChar;

    //Event init
    handler_uart[1] = handler;
    event_newline_uart[1] = process_alloc_event();
}




hopefully someone can give me an idea of what is going wrong. I'm only receiving 16 byte ...
even when i remove the break command in the handler.

thanks

Outcomes