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
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!
-----------------------------------------------------------------------------------------------------------------------
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.
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!
-----------------------------------------------------------------------------------------------------------------------
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