I am using the SCI driver provided by HALCOGEN and FreeRTOS. I am using a GIO to send an enable line to an external RS485 transceiver. When I need to transmit I raise the GIO and transmit. My problem is I need to clear the GIO when the transmission is completed. I have tried clearing the GIO in linHighLevelInterrupt() when the tx_length is zero but the GIO clears too early and the last byte does not get sent by the transceiver. It appears that I am getting the TX ready interrupt before the TX shift register has finished sending all bits. How can I get an interrupt when the transmission is truly complete? Here's my modification of the linHighLevelInterrupt() switch case 12:
case 12U:
/* transmit */
/*SAFETYMCUSW 30 S MR:12.2,12.3 <APPROVED> "Used for data count in Transmit/Receive polling and Interrupt mode" */
--g_sciTransfer_t.tx_length;
if ((g_sciTransfer_t.tx_length) > 0U)
{
uint8 txdata = *g_sciTransfer_t.tx_data;
scilinREG->TD = (uint32)(txdata);
/*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
g_sciTransfer_t.tx_data++;
}
else
{
scilinREG->CLEARINT = SCI_TX_INT;
sciNotification(scilinREG, (uint32)SCI_TX_INT);
// if TX send reg is empty then we can
// turn off the ENABLE line
gioSetBit(gioPORTA, LIN_EN, FALSE);
}
break;