I am developing my application with KDS 3.0.0 + KSDK 1.3.0 + PEx + MQX_Standard on my K66 custom board.
I have to drive an UART in interrupt mode, so I use the fsl_uart PEx component, which relays on fsl_uart_driver and fsl_uart-hal KSDK modules.
With that component I can start receiving and/or transmitting in interrupt mode through the UART_DRV_ReceiveDATA() and UART_DRV_SendData() functions. I can install RX and TX call-back functions, which are called from the UART interrupt handler upon every character reception and transmission events.
Unfortunately, the TX call-back function is called only upon a TX Data Register Empty (TDRE) event. Instead, in may application I need to catch also the Transmission Complete (TC) event: how can I get that functionality with KSDK?
Unfortunately, the How To RS485 with KSDK component fsl_uart discussion does not help me.
Should I use the UART_HAL_SetIntMode() function to enable the TC event (TCIE) as interrupt source? And how?
Even if TC event were enabled as interrupt source, should I manually add the TC event handler into the UART interrupt handler generated by PEx and define and use a new TC call-back function of my own?
Thank you for your help.
Hello Alessandro,
You can use this code to enable the TC interrupt :
UART_BWR_C2_TCIE(UART1, 1u);
It is defined in the file of :MK22F51212_extension.h (KSDK_1.3.0\platform\devices\MK22F51212\include)
Hope it helps
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Have a great day,
Alice
Thank you, Alice.
Now I know how to enable the TC interrupt.
Should I enable it in UART_DRV_CompleteSendData() function after the last transmitted character?
But what about handling the TC interrupt? Should I manually modify the UART_DRV_IRQHandler() function and add my TCcallback() function?
Hello Alessandro,
- I think you can enable the TC interrupt on the UART of initialization code .
- Yes , you need install the TCcallback() function by yourself , you can refer to the "UART_DRV_InstallTxCallback" function .
Hope it helps
Alice