receive 9-bit data via UART1 using LPC1754?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

receive 9-bit data via UART1 using LPC1754?

1,097件の閲覧回数
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;

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

937件の閲覧回数
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!
-----------------------------------------------------------------------------------------------------------------------

937件の閲覧回数
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 件の賞賛
返信

937件の閲覧回数
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 件の賞賛
返信