This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problems with SCIA port and FIFO when using motorware

Other Parts Discussed in Thread: CONTROLSUITE

I'm trying to use the SCIA in FIFO mode to send 4 bytes out at a time and to receive 1 byte at a time, without much success.
The peripheral is initialised with the following function :-

void HAL_setupSciA(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;

SCI_clearAllRegs(obj->sciAHandle); //clears all bits in following regs
SCI_enableChannels(obj->sciAHandle); //sets bit 15 in SCIFFTX
//SCI_enableTxFifoEnh(obj->sciAHandle); //sets bit 14 in SCIFFTX (enable FIFO operation)
SCI_enableTxFifo(obj->sciAHandle); //sets bit 13 in SCIFFTX
SCI_clearTxFifoInt(obj->sciAHandle); //clears bit 7 in SCIFFTX
SCI_setTxFifoIntLevel(obj->sciAHandle, SCI_FifoLevel_4_Words); //in SCIFFTX
SCI_enableTxFifoInt(obj->sciAHandle); //sets bit 5 in SCIFFTX

SCI_clearRxFifoOvf(obj->sciAHandle); //clears bit 14 in SCIFFRX
SCI_enableRxFifo(obj->sciAHandle); //sets bit 13 in SCIFFRX
SCI_clearRxFifoInt(obj->sciAHandle); //clears bit 6 in SCIFFRX
SCI_setRxFifoIntLevel(obj->sciAHandle, SCI_FifoLevel_1_Word); //in SCIFFRX

SCI_setNumStopBits(obj->sciAHandle, SCI_NumStopBits_One); //in SCICCR
SCI_disableParity(obj->sciAHandle); //clear bit 5 in SCICCR
SCI_disableLoopBack(obj->sciAHandle); //clear bit 4 in SCICCR
SCI_setMode(obj->sciAHandle,SCI_Mode_IdleLine); //clear bit 3 in SCICCR
SCI_setCharLength(obj->sciAHandle, SCI_CharLength_8_Bits); //bits 2-0 in SCICCR

SCI_disableRxErrorInt(obj->sciAHandle); //clear bit 6 in SCICTL1
SCI_disableTxWake(obj->sciAHandle); //clear bit 3 in SCICTL1
SCI_disableSleep(obj->sciAHandle); //clear bit 2 in SCICTL1
SCI_enableTx(obj->sciAHandle); //set bit 1 in SCICTL1
SCI_enableRx(obj->sciAHandle); //set bit 0 in SCICTL1

//SCI_enableTxInt(obj->sciAHandle); //set bit 1 in SCICTL2
SCI_enableRxInt(obj->sciAHandle); //set bit 0 in SCICTL2

SCI_setBaudRate(obj->sciAHandle,23); //set baud rate value to 115.2Kbaud (-?%)
SCI_enable(obj->sciAHandle); //set? bit 5 in SCICTL1

return;
} // end of HAL_setupSciA() function

When the line in Bold text above is commented out, single characters can be received and will generate an interrupt that jumps into my interrupt routine. If the line //SCI_enableTxFifoEnh(obj->sciAHandle); is uncommented, the received byte appears in the receive buffers and the interrupt flag is set in SCIFFRX, but the jump to the interrupt routine does not occur. The RXFFIL and RXFFST bits both have a value of 1 when this occurs.
So, setting the SCIFFENA bit in SCIFFTX prevents the receive interrupt from functioning
A second problem occurs when SCIFFENA is set, with transmissions. Although the FIFO transmission of 4 bytes seems to work correctly, in that 4 bytes appear on the transmit line, continuous interrupts are generated after one transmission, and the interrupt routine is continuously entered.
At the end of the Tx interrupt I've got this code
HAL_clearSciATxflags(halHandle);
HAL_ackSCIA(halHandle);
First line calls
void HAL_clearSciATxflags(HAL_Handle handle)
{
  HAL_Obj   *obj = (HAL_Obj *)handle;
  SCI_clearTxFifoInt(obj->sciAHandle);   // Clear Interrupt flag
  return;
}  // end of HAL_clearSciATxflags() function
which calls
void SCI_clearTxFifoInt(SCI_Handle sciHandle)
{
  SCI_Obj *sci = (SCI_Obj *)sciHandle;
  // set the bits
  sci->SCIFFTX |= SCI_SCIFFTX_INTCLR_BITS;
  return;
} // end of SCI_clearTxFifoInt() function
which should set bit 6 in SCIFFTX to clear the interrupt bit in bit 7, but it doesn't. Before and after this code
SCIFFTX = 0xE0A4, so I can't clear the interrupt bit.
I can't find any explanation in the documentation for what is happening here and really need some advice.
Geoff

  • Geoff,

    In addition to clearing the interrupt in SCI registers I think you also need to clear the interrupt in the PIE block.  It looks like this is done in PIE interrupt block 9.  

    I think if this isn't cleared it will generate continuous interrupts.

  • Adam,

    It's not the continuous Tx interrupts that are causing the Rx interrupt problem, because when I have the Rx problem, I don't have the Tx interrupt enabled in my code. To verify this I put breakpoints at the start of both the Rx and Tx interrupts, and with this line :-

    SCI_enableTxFifoEnh(obj->sciAHandle); //sets bit 14 in SCIFFTX (enable FIFO operation)

    commented out, the code hits the Rx breakpoint, but not the Tx breakpoint, and with the line uncommented, it hits neither Rx or Tx breakpoints, proving that the Tx interrupt isn't enabled.

    Also the PIE interrupt is being cleared, as far as I can see by the following code at the end of the interrupt

    HAL_ackSCIA(halHandle);

    which calls  

    PIE_clearSciIntA(obj->pieHandle);

    which calls

    pie->PIEACK |= 0x0100;


    That code is the direct equivalent of what's done in the ControlSuite SCI example I think.

    Geoff

  • Geoff,

    Wanted to let you know we are looking into this, although we don't have an answer as of yet.  Will keep you posted but I'm trying to determine if this is HW/Setup related or SW related at the moment.

    Matt