Can't get UART to work with even/odd parity on K70

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

Can't get UART to work with even/odd parity on K70

2,054 Views
bilalwasim
Contributor II

Hi people. I'm currently working on UART driver for K70 board. The driver seems to work correctly, and I'm able to transmit and receive data correctly. I'm using TX(polling), and RX(Interrupt). However, when I change the parity of the data transmission from none to odd/even, I only receive garbage data on the console. Register setting for enabling parity is :
i- set the C1[PE] = 1
ii- set the C1[PT] = 0(for even parity), and C1[PT] = 1(for odd parity).
This is how the configuration is supposed to be, but it doesn't work. I've checked this with teraterm, putty and realterm. Moreover, I've written a script in python as well, but they all show the same behavior.
I'm using 8 bit data with 1 stop bit, and 115200 bps as my baud rate. Someone told me that this is probably a known issue, and there are workarounds. Am I supposed to use 9 bit data when I'm enabling parity? Is this true? Can anyone guide me in the right direction here?

Best,
Bilal

Labels (1)
Tags (1)
4 Replies

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Bilal Wasim,

     How did you configure your PC teraterm? If you configre it as 8bits data+ 1bits stop+odds.

     Then you should choose the MCU as 9 bits mode, please configure UARTx_C1[M]=1, because one odds bit also  followed in the MCU data, if you just configure MCU as 8 bits data and enable the odds, then actually, the MCU uart data is just 7 bits.

     In conclusion, set UARTx_C1[M] bit.

Wish it helps you!

Have a great day,
Kerry

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

0 Kudos

1,288 Views
otavioborges
Contributor III

I had same problem with UART on KE04 and KE02 sub-families.

I would suggest marking this on reference manual, like a footnote on UARTx_C1 parity bits description. I've struggled for a while with UART parity until reaching this thread.

Mentions of 9th bit being used as parity is quite hidden on reference and not mentioned on Functional Description.

1,288 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Otavio Borges,

   Actually, all the kinetis have this feature, just get this feature is OK.

Wish it helps you!

Have a great day,
Kerry

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

0 Kudos

1,288 Views
mjbcswitzerland
Specialist V

Hi

I have attached the UART driver from the uTasker project as reference. It support UART and LPUARTs on K, KL, KV, KM, KE, KEA, KW in interrupt or DMA modes, with software and hardware flow control etc. (as well as true 2 stop bit or 9 bit operation...).

However, to solve the present problem that you have I believe that you just need to set the M bit when you enable parity in 8 bit mode:

8 bit mode
==========
Odd parity:
    UART_C1 = (UART_C1_M | UART_C1_PE | UART_C1_PT_ODD); // program odd parity
Even parity:
    UART_C1 = (UART_C1_M | UART_C1_PE | UART_C1_PT_EVEN); // program even parity
No parity:
    UART_C1 = 0;


7 bit mode
==========
Odd parity:
    UART_C1 = (UART_C1_PE | UART_C1_PT_ODD); // program odd parity
Even parity:
    UART_C1 = (UART_C1_PE | UART_C1_PT_EVEN); // program even parity
No parity:
    UART_C1 = 0; // no parity - the UART in the Kinetis will use address mark at the 8th bit position in 7 bit character mode without a parity setting


Regards

Mark
Kinetis for professionals: http://www.utasker.com/kinetis.html
UART: http://www.utasker.com/docs/uTasker/uTaskerUART.PDF
For high-performance K70: http://www.utasker.com/kinetis/TWR-K70F120M.html / http://www.utasker.com/kinetis/EMCRAFT_K70F120M.html