lpcware

UART2 not woking?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by TKoe on Wed Jul 11 07:44:42 MST 2012
Hi!

I'm using the Embedded Artists LPC1788 development board. Unfortunately I can't get the UART2 to work which is routed to the 9-pin DSUB connector. I found that the nxpusblib already comes with a library for the UART so I didn't write any data to the registers themselves.

Just wanted to make sure that my code is okay, really.
Here it is:
UART.h
[collapse]<code>
#ifndef UART_H_
#define UART_H_

#include "LPC177x_8x.h"
#include "lpc177x_8x_uart.h"
#include "lpc177x_8x_pinsel.h"

LPC_UART_TypeDef * UART_Used_td;
UART_ID_Type UART_Used;

#define UART_DATA_BUFFER_MAX 100
uint8_t UART_Data_Buffer[UART_DATA_BUFFER_MAX];
uint8_t UART_Data_Buffer_length;

void UART_RxHandler(void);
void UART_Send_Byte(const uint8_t data);
void UART_Send_Data(uint8_t * data, const uint32_t length);
void UART_Init_local(void);

#endif /* UART_H_ */
</code>[/collapse]


UART.c
[collapse]<code>
void UART_RxHandler(void)
{
if (UART_Data_Buffer_length)
{
UART_Send_Data(UART_Data_Buffer, UART_Data_Buffer_length);
UART_Data_Buffer_length = 0;
}
}


void UART2_IRQHandler(void)
{
if (UART_Data_Buffer_length < UART_DATA_BUFFER_MAX)
{
UART_Data_Buffer[UART_Data_Buffer_length++] =
UART_ReceiveByte(UART_Used_td);
}
//else
//{
//UART_Overflow_Flag = true;
//}
}

void UART_Send_Byte(const uint8_t data)
{
UART_SendByte(UART_Used_td, data);
}

void UART_Send_Data(uint8_t *  data, const uint32_t length)
{
UART_Send(UART_Used_td, data, length, BLOCKING);
}

void UART_Init_local(void)
{
UART_Used_td = (LPC_UART_TypeDef *)LPC_UART2;
UART_Used = UART_2;
UART_CFG_Type UART_config =
{
.Baud_rate = 115200,
.Parity = UART_PARITY_NONE,
.Databits = UART_DATABIT_8,
.Stopbits = UART_STOPBIT_1
};

UART_FIFO_CFG_Type UART_FIFO_config =
{
.FIFO_ResetRxBuf = ENABLE,
.FIFO_ResetTxBuf = ENABLE,
.FIFO_DMAMode = ENABLE,
.FIFO_Level = UART_FIFO_TRGLEV0
};

UART_Init(UART_Used_td, &UART_config);
UART_FIFOConfig(UART_Used, &UART_FIFO_config);
UART_TxCmd(UART_Used_td, ENABLE);
UART_IntConfig(UART_Used, UART_INTCFG_RBR, ENABLE);
PINSEL_ConfigPin(0, 10, 0x001); // Tx
PINSEL_ConfigPin(0, 11, 0x001); // Rx
}
</code>
</code>[/collapse]

What do you think, is there something misssing/wrong in the code or did I overlook something in the board's routing?


Regards,
Tim

Outcomes