How can I do 2 stop bits on a K60 UART2 at 9600 baud rate

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

How can I do 2 stop bits on a K60 UART2 at 9600 baud rate

1,524 Views
batwings
Contributor II

I don't see a way to do 2 stop bits, or on the K60 UARTs.  I'm using UART2

I need to connect to a device via rs232 to do modbus communication with the following settings:

The serial communication parameters are

 BPS: 9600 baud

 Parity: None

 Data bits: 8

 Stop bits: 2

 Flow control: None

Any suggestions?

0 Kudos
4 Replies

822 Views
egoodii
Senior Contributor III

Or, a 'more direct' method would be to set the UART for '9 bit' mode (UART2_C1 'M'), and then in UART2_C3 set/confirm-valid-stop#1 'bit 8' as T8/R8.

0 Kudos

822 Views
batwings
Contributor II

Thanks for the quick suggestions.   I will give this a try and report back!

0 Kudos

822 Views
mjbcswitzerland
Specialist V

Hi Jason

MODBUS never uses 2 stop bits for its communication (see MODBUS over serial line specification) - it has a fixed 10 bit length for both ASCII and RTC.

If nevertheless required, the method for the K series is also described here: K20 UART with 2 stop bit or parity although can't be used in DMA mode.

The UART driver in the uTasker project will respect true 2 stop bits on Kinetis K-parts if the option TRUE_UART_TX_2_STOPS is enabled and the UART is opened for 2 stop bit mode (on all 6 UARTs). µTasker Kinetis support

If you are developing a MODBUS project, be advised that a complete solution for the Kinetis is available at µTasker MODBUS Extension pack which supports serial master and/or slave on all UARTs in RTU and/or ASCII modes, handles RS485 mode, as well as multiple MODBUS TCP sessions (master and/or slaves) with gateway and routing capability.

Comprehensive user's manual: http://www.utasker.com/docs/MODBUS/uTasker_MODBUS.PDF

and industrially proven in Coldfire (and more recently Kinetis) projects since 2009. It was also embedded in support equipment controlling the Claw used by U2 on their 306° World Tour: µTasker Project Page

Regards

Mark

Kinetis: http://www.utasker.com/kinetis.html

K60: µTasker Kinetis TWR-K60N512 support / µTasker Kinetis TWR-K60D100M support / µTasker Kinetis TWR-K60F120M support

For the complete "out-of-the-box" Kinetis experience and faster time to market


0 Kudos

822 Views
egoodii
Senior Contributor III

Reception of two-stop bits, when the controller is only set for one, isn't a problem of course -- excepting that you won't get any kind of 'fault' if the 2nd stop bit isn't proper.  For the TX side, I think you will find that if you work with the transmit-shift-register-empty bit/interrupt for loading the 'next byte' that you will get that extra stop bit on TX, as it takes one bit time for a data byte to make it from the buffer to the TX shift register.

0 Kudos