7 data bits, odd parity is required for operation with some existing equipment.
After reading through the RM and reading some answers on this site I thought I could use IO_IOCTL_SERIAL_SET_DATA_BITS to set for 8-bit mode (for 7 data bits and 1 parity bit) and IO_IOCTL_SERIAL_SET_PARITY to set parity to IO_SERIAL_PARITY_ODD. But - when trying to communicate with a port set like this, a PC terminal program shows garbage characters.
Stepping through the MQX code shows that in _kuart_polled_ioctl() - setting ODD parity also sets 9-bit mode: sci_ptr->C1 |= UART_C1_M_MASK;
case IO_IOCTL_SERIAL_SET_PARITY:
switch (*param_ptr) {
case IO_SERIAL_PARITY_NONE:
/* disable parity only if enabled (once) */
if (sci_ptr->C1 & UART_C1_PE_MASK)
{
sci_ptr->C1 &= (~ (UART_C1_PE_MASK | UART_C1_PT_MASK));
/* disable parity bit */
if (sci_ptr->C4 & UART_C4_M10_MASK)
{
sci_ptr->C4 &= (~ UART_C4_M10_MASK);
}
else
{
sci_ptr->C1 &= (~ UART_C1_M_MASK);
}
}
break;
case IO_SERIAL_PARITY_ODD:
/* can't enable parity in 2 stop bits mode */
if (IO_SERIAL_STOP_BITS_1 != (io_info_ptr->FLAGS & IO_SERIAL_STOP_BITS_1))
{
return MQX_INVALID_CONFIGURATION;
}
/* if parity already enabled, just set the requested one */
if (sci_ptr->C1 & UART_C1_PE_MASK)
{
sci_ptr->C1 |= UART_C1_PT_MASK;
}
else
{
/* enable odd parity */
sci_ptr->C1 |= (UART_C1_PE_MASK | UART_C1_PT_MASK);
/* enable parity bit */
if (sci_ptr->C1 & UART_C1_M_MASK)
{
sci_ptr->C4 |= UART_C4_M10_MASK;
}
else
{
sci_ptr->C4 &= (~ UART_C4_M10_MASK);
sci_ptr->C1 |= UART_C1_M_MASK;
}
}
break;
case IO_SERIAL_PARITY_EVEN:
/* can't enable parity in 2 stop bits mode */
if (IO_SERIAL_STOP_BITS_1 != (io_info_ptr->FLAGS & IO_SERIAL_STOP_BITS_1))
{
return MQX_INVALID_CONFIGURATION;
}
/* if parity already enabled, just set the requested one */
if (sci_ptr->C1 & UART_C1_PE_MASK)
{
sci_ptr->C1 &= (~ UART_C1_PT_MASK);
}
else
{
/* enable even parity */
sci_ptr->C1 |= UART_C1_PE_MASK;
sci_ptr->C1 &= (~ UART_C1_PT_MASK);
/* enable parity bit */
if (sci_ptr->C1 & UART_C1_M_MASK)
{
sci_ptr->C4 |= UART_C4_M10_MASK;
}
else
{
sci_ptr->C4 &= (~ UART_C4_M10_MASK);
sci_ptr->C1 |= UART_C1_M_MASK;
}
}
break;
default:
return MQX_INVALID_PARAMETER;
}
break;