UART2 not woking?

cancel
Showing results for 
Search instead for 
Did you mean: 

UART2 not woking?

158 Views
lpcware
NXP Employee
NXP Employee
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
Labels (1)
0 Kudos
2 Replies

25 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TKoe on Thu Jul 12 07:45:52 MST 2012
Ah, thank you!
I didn't know about this repository. This is a great help :)

Best Regards,
Tim
0 Kudos

25 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lien.Nguyen on Thu Jul 12 02:36:57 MST 2012
Hi Tim,
You can refer to UART examples at the link http://sw.lpcware.com/?p=lpc177x_8x.git&a=summary.
The abstract.txt file in each example will give you the steps to run.

Best Regards,
Lien
0 Kudos