LPC54608 USART 9 bit mode

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC54608 USART 9 bit mode

1,403 次查看
sjlprescient
Contributor I

Is there anyway to put the USART into 9 bit data mode and then be able to set the 9th bit?  We are trying to communicate with an external power supply over an RS-485 interface and the controller on the power supply uses a 9 bit data frame consisting of 8 bits of data with an additional framing bit.  The first byte always has a 1 for the framing bit, all additional bytes have a 0.  

I'm just not sure how to set this 9th bit on a per byte basis.

Anyone managed to do this with this device?

Thanks for your help

标签 (1)
0 项奖励
回复
5 回复数

1,084 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello scott lawson,

In the user manual, chapter 25 you will find the following information. 

pastedImage_2.png

To work with 9 bits of data you have to modify the CFG register of the UART as shown in the next image. 

pastedImage_3.png

Link to the user manual

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------

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

----------------------------------------------------------------------------------------------------------------------- 

0 项奖励
回复

1,084 次查看
sjlprescient
Contributor I

Thanks Victor,

I was able to get the hardware to transmit using 9 bit mode, but i was not able to figure out how to set the 9th bit using the library code for DMA transfer, or non blocking transfer.  Looking through the library code i see only data accesses/transfers using 8 bit pointers and nothing that handles the 9th bit being moved into the base->FIFOWR register.  

I also noticed that the #define _usart_data_len statement in the header file that sets the register setting was missing a value for the 9 bit setting altogether, its easy enough to add an additional entry for the 9 bit setting but the fact that it is missing would lead me to beleive that the 9 bit format is not supported by the libraries right now.

At this point i think I am going to have to create a custom version of the handlers to do what i want.  Unless i really am missing something obvious.

Thanks for your help

Scott

0 项奖励
回复

1,084 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Scott,

If you want to use the 9th bit for addressing in multidrop mode then you just have to set the ADDRDET bit in the CTL register and you can set the 9th bit using a mask. If you are planning to use the 9th bit in a different way then yes, you have to modify the drivers according to your needs. 

Regards,

Victor. 

0 项奖励
回复

1,084 次查看
sjlprescient
Contributor I

The 9th bit is set to 1 on the first byte transmitted on the bus, all subsequent  bytes have the 9th bit set to 0.  This is the protocol used on the power supply we are trying to interface with.   Is this how the multi drop mode functions? Setting the 9th bit only on initial address byte?

From what i can gather regarding the ADDRDET bit in the CTL register this is used on receiving of bytes only and not with transmission of data out to slave devices.

0 项奖励
回复

1,084 次查看
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Scott,

If you want to set the 9th bit to one you can do something like the following: 

UARTx->TXDATA = (uint32_t)data|0x100;

And to clear the 9th bit you can use the following mask: 

UARTx->TXDATA = (uint32_t)data&~0x100;

Regards,

Victor. 

0 项奖励
回复