receive 9-bit data via UART1 using LPC1754?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

receive 9-bit data via UART1 using LPC1754?

1,098 Views
stijn_paesen
Contributor I
Hello,

How to set up the UART1 to receive a 9-bit data (RS485) message for LPC1754?

1 start bit, 9 data bits, 1 stop bit

Is setting parity needed? I get every byte I receive an parity error?

Regards,
Stijn

I set:
UART_InitStruct->Baud_rate = 460800;
UART_InitStruct->Databits = UART_DATABIT_8;
UART_InitStruct->Parity = UART_PARITY_SP_1;
UART_InitStruct->Stopbits = UART_STOPBIT_1;

UART_FIFOInitStruct->FIFO_DMAMode = DISABLE;
UART_FIFOInitStruct->FIFO_Level = UART_FIFO_TRGLEV0;
UART_FIFOInitStruct->FIFO_ResetRxBuf = ENABLE;
UART_FIFOInitStruct->FIFO_ResetTxBuf = ENABLE;

rs485cfg.AutoDirCtrl_State = ENABLE;
rs485cfg.DirCtrlPin = UART1_RS485_DIRCTRL_DTR;
rs485cfg.DirCtrlPol_Level = SET;
rs485cfg.DelayValue = 50;
rs485cfg.NormalMultiDropMode_State = ENABLE;
rs485cfg.AutoAddrDetect_State = DISABLE;
//rs485cfg.MatchAddrValue = 0;
rs485cfg.Rx_State = ENABLE;

Labels (1)
0 Kudos
Reply
3 Replies

938 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Stijin,

    LPC175X can't support 9 bit data size, please check the user manual:

pastedImage_1.png

UART1 module can't support the 9 bits data size, just 5.6.7 and 8 bits.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

938 Views
stijn_paesen
Contributor I

Hello,

 

Yesterday I managed to receive data and address bytes

 

            UART_InitStruct->Baud_rate = 454545;

            UART_InitStruct->Databits = UART_DATABIT_8;

            UART_InitStruct->Parity = UART_PARITY_NONE;

            UART_InitStruct->Stopbits = UART_STOPBIT_1;

 

            rs485cfg.AutoDirCtrl_State = ENABLE;

            rs485cfg.DirCtrlPin = UART1_RS485_DIRCTRL_DTR;

            rs485cfg.DirCtrlPol_Level = SET;

            rs485cfg.DelayValue = 50;

            rs485cfg.NormalMultiDropMode_State = ENABLE;

            rs485cfg.AutoAddrDetect_State = DISABLE;

            rs485cfg.MatchAddrValue = 0;

            rs485cfg.Rx_State = ENABLE;

 

bytes with 9th bit 0, data bytes are received correctly

bytes with 9th bit 1, address bytes are received with parity error, but can be read when handling the error

 

Not the most nice way but it works.

 

Regards,

Stijn

0 Kudos
Reply

938 Views
kerryzhou
NXP TechSupport
NXP TechSupport

HI Stijin,

   Thank you for your updated information. Actually, it is just caused by the hardware can't support the 9 bit data directly.

  So, if you can receive the data correctly, just have parity error, I think you can check the error, if it is the parity error,  ignore it.

  If you still have question about it, please kindly let us know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply