I'm developing a project based on K66, using MCUXpresso 11.2.0 and SDK 2.6.
I have to implement a serial protocol that uses 9 bit data length (with the ninth bit acting as address mark). I modified the uart drivers (fsl_uart and fsl_uart_freertos files) to handle the ninth bit (and to add a timeout handling): now everything is working fine.
Nevertheless the uart speed is high (125000 bps) and the UART used have an only 1 byte FIFO depth (UART4), so the character length is 88 µs: every character received an interrupt must be serviced. Sometimes it happens that a character is lost (and therefore all the packet is lost since there is a crc check) due to a delay in servicing the interrupt request, even if the UART interrupt priority is the highest (maybe this is caused by the FreeRTOS scheduler that can disable the interrupts for a little time).
In another application where the 8 bit data length is used, I developed an UART FreeRTOS driver that uses DMA that is working great.
My question is: can the UART DMA driver (even without FreeRTOS) handle the 9 bit data lenght? I've searched informations about it in the K66 reference manual and online, but with non success.
Hello Francesco and Confused Cake,
You could do it the following way:
The C3 register that contains the 9 bit is contiguous to the data register, so you could set the DMA transmission for two bytes width and filter the C3 register to only take the R8 or T8 bit depending on if you are receiving or transmitting.
I will suggest checking how the LPUART_ReceiveEDMA/LPUART_TransmitEDMA configure the DMA and modify the byte width and change the Date address for the C3 address.
I already modified the API on to handle the talktosonic 9 bit communication (and a tx/rx timeout) and it's working, but sometimes a character is lost. I think the reason is because it can't handle interrupts in time (speed is 125000 bps and the UART4 peripheral have only 1 byte FIFO); so I'd want to use DMA.
In the LPUARTx_CTRL the M bit is used to enable the 9-bit data character, unfortunately in the SDK still there isn't support for 9-bit communication, so you will need to modify the APIs and type data to support it.
Many thanks for your answer, sorry for the late processing, but I was on holiday until this morning.
I don't use LPUART, I use UART (UART4).
I already modified the API on fsl_uart and fsl_uart_freertos files to handle the 9 bit communication (and a tx/rx timeout) and it's working, but sometimes a character is lost. I think the reason is because it can't handle interrupts in time (speed is 125000 bps and the UART4 peripheral have only 1 byte FIFO); so I'd want to use DMA.
I already developed a UART FreeRTOS driver that uses DMA for an application that uses 8 bit communication.
My doubt is if the DMA peripheral can handle the UART 9 bit communication.