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.

TMS320F28027F: A SCI_RX interrupt occurs immediately after SCI initialization, then the same interrupt no longer occurs after exiting the handler.

Part Number: TMS320F28027F
Other Parts Discussed in Thread: MOTORWARE, C2000WARE

Tool/software:

 

Hi.

We use a SCIA module as UART with FIFO by modifying motorware_1_01_00_18.

We encountered some strange behavior. Do you have any idea what is causing this.

I attach below the source code and some screenshots.


1) In line 33, flaming or parity error flags (SCIRXBUF.SCIFFFE, SCIRXBUF.SCIFFPE) are set 1 when enabling TXFIFO.

We don't expect this before enabling RX. At this time, RXFIFO is empty and no RX errors. (SCIFFRX.RXFFST=0, SCIRXST.RXERROR=0)

2) In line 41, An RXFIFO interrupt flag (SCIFFRX.RXFFINT) is set 1 when setting the RXFIFO interrupt level.

Also it confuses us why it is set 1 even though FIFO is empty.

3) In line 89, an SCI reception interrupt occurs after enabling interrupts.

4) RXERROR is set to 1 in the SCI reception interrupt, and MCU no longer receives any data to determine as a reception error and discard continuously.


void main(void)
{
    // Only used if running from FLASH
    // Note that the variable FLASH is defined by the project
    #ifdef FLASH
    // Copy time critical code and Flash setup code to RAM
    // The RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
    // symbols are created by the linker. Refer to the linker files.
    memCopy((uint16_t *)&RamfuncsLoadStart,(uint16_t *)&RamfuncsLoadEnd,(uint16_t *)&RamfuncsRunStart);

    #endif

    pstHalHandle_ = HAL_init(&stHalObj_, sizeof(stHalObj_));

    // disable global interrupts
    CPU_disableGlobalInts(pstHalHandle_->cpuHandle);
    // disable cpu interrupts
    CPU_disableInts(pstHalHandle_->cpuHandle);
    // clear cpu interrupt flags
    CPU_clearIntFlags(pstHalHandle_->cpuHandle);

    HAL_setupClks(pstHalHandle_);
    HAL_setupPll(pstHalHandle_,PLL_ClkFreq_60_MHz);
    HAL_setupPie(pstHalHandle_);
    HAL_setupPeripheralClks(pstHalHandle_);
    HAL_setupGpios(pstHalHandle_);

    // reset SCI
    SCI_reset(pstHalHandle_->sciAHandle);

    // SCIFFTX
    SCI_resetChannels(pstHalHandle_->sciAHandle);
    SCI_enableTxFifoEnh(pstHalHandle_->sciAHandle);
    SCI_clearTxFifoInt(pstHalHandle_->sciAHandle);
    SCI_disableTxFifoInt(pstHalHandle_->sciAHandle);
    SCI_setTxFifoIntLevel(pstHalHandle_->sciAHandle, SCI_FifoLevel_Empty);
    // SCIFFRX
    SCI_resetRxFifo(pstHalHandle_->sciAHandle);
    SCI_clearRxFifoInt(pstHalHandle_->sciAHandle);
    SCI_disableRxFifoInt(pstHalHandle_->sciAHandle);
    SCI_setRxFifoIntLevel(pstHalHandle_->sciAHandle, SCI_FifoLevel_1_Word);

    // SCICCR
    SCI_setNumStopBits(pstHalHandle_->sciAHandle,SCI_NumStopBits_One);
    SCI_setParity(pstHalHandle_->sciAHandle,SCI_Parity_Even);
    SCI_enableParity(pstHalHandle_->sciAHandle);
    SCI_disableLoopBack(pstHalHandle_->sciAHandle);
    SCI_setMode(pstHalHandle_->sciAHandle, SCI_Mode_IdleLine);
    SCI_setCharLength(pstHalHandle_->sciAHandle,SCI_CharLength_8_Bits);

    // SCICTL1
    SCI_disableRxErrorInt(pstHalHandle_->sciAHandle);
    SCI_disable(pstHalHandle_->sciAHandle);
    SCI_disableTxWake(pstHalHandle_->sciAHandle);
    SCI_disableSleep(pstHalHandle_->sciAHandle);
    SCI_enableTx(pstHalHandle_->sciAHandle);
    SCI_enableRx(pstHalHandle_->sciAHandle);

    // SCICTL2
    SCI_disableRxInt(pstHalHandle_->sciAHandle);
    SCI_disableTxInt(pstHalHandle_->sciAHandle);

    // SCIH-SCIL
    SCI_setBaudRate(pstHalHandle_->sciAHandle,SCI_BaudRate_115_2_kBaud);

    // SCIPRI
    SCI_setPriority(pstHalHandle_->sciAHandle,SCI_Priority_FreeRun);

    // enable SCI
    SCI_enable(pstHalHandle_->sciAHandle);

    // regester interrupt handler
    PIE_registerPieIntHandler(pstHalHandle_->pieHandle, PIE_GroupNumber_9, PIE_SubGroupNumber_1, sciARxISR);

    // enable the PIE interrupts associated with the SCI interrupts
    // enable SCIA RX interrupt in PIE
    PIE_enableInt(pstHalHandle_->pieHandle,PIE_GroupNumber_9,PIE_InterruptSource_SCIARX);

    // enable SCI RX interrupts
    // enable SCIA RX FIFO interrupt
    // enable SCIA RX Error interrupt
    SCI_enableRxFifoInt(pstHalHandle_->sciAHandle);
    SCI_enableRxErrorInt(pstHalHandle_->sciAHandle);

    CPU_enableInt(pstHalHandle_->cpuHandle,CPU_IntNumber_9);


    // Enable interrupts
    CPU_enableGlobalInts(pstHalHandle_->cpuHandle);
    // Enable the debugger interrupt
    CPU_enableDebugInt(pstHalHandle_->cpuHandle);

in line 33.

in line 41.

in line 89.

Thanks for your help.

  • Hi Atsuki,

    Are you saying that the error flag is set and causes you to enter an interrupt prematurely at all? Or are you just seeing that the error flag is set?

    Are you using any of our C2000Ware examples as a reference for code? If so which one? And If not, please first be sure to look at and compare code/init procedure with our SCI examples in the C2000Ware "device_support" folder as these SCI initializations have been verified.

    Best Regards,

    Allison

  • Hi Allison.

    We just saw it is set. I don't make sense whether they are related each other or not. Now we think those behaviors don't have relationship probably because of the reason below.

    After posting, we tried to change baudrate from 115200 to 125000 then strange interrupts no longer occurs and it seems to be able to receive. but why?

    We referred to a post in the link given below for coding. Following your advice, we compared with the C2000Ware's sample code. We found some difference and tried to correct to match it, but still it have unsolved.

    https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/378725/implement-sci-on-28027f?tisearch=e2e-sitesearch&keymatch=MOTORWARE%2520SCI

    Thanks.

  • Hi  Atsuki,

    Can you please try the following procedure to configure the SCI module during initialization (do these in order):

    • First, ensure all SCI interrupts are disabled
    • Next, clear the interrupt status of all SCI interrupts (RXFF, TXFF, FE, OE, PE, RXERR, BRKDT, TXRDY) by clearing and then setting SCI’s CTL1.SWRESET bit and setting SCI’s FFTX.TXFFINTCLR and FFRX.RXFFINTCLR bits.
    • Next, clear the overflow status bit by setting SCI’s FFRX.RXFFOVRCLR bit
    • Next, reset the RX and TX FIFOs by clearing and then setting the FFTX.TXFIFORESET
    • Next, reset the TX and RX channels of the device by clearing and then setting the FFTX.SCIRST bit.
    • Next, actually configure all the SCI settings for your system, like baud rate (SCIHBAUD+SCILBAUD registers), parity+data length+stop bits (SCICCR register).
    • Next, enable the module by setting CTL1.TXENA, CTLA.RXENA, and CTL1.SWRESET. This also performs a software reset of the SCI module to prepare it for running.
    • Next, if using the FIFO, set the appropriate FIFO interrupt levels by setting the levels in the FFTX.TXFFIL and FFRX.RXFFIL fields. The FIFO levels must be chosen to allow sufficient time for the interrupt to handle the data requests before FIFO overflows. For long SCI ISRs, make sure to interrupt sufficiently early, or move the processing out of the ISR and only do data movement in the SCI ISR (recommended).
    • Finally, if using the FIFO, enable the FIFO by setting the FFTX.SCIRST (if not set, though it is safe to set again), FFTX.SCIFFENA, FFTX.TXFIFORESET, and FFRX.RSFIFORESET bits.
    • Finally, enable the module again by setting the CTL1.TXENA, CTLA.RXENA, and CTL1.SWRESET bits. This also performs a software reset of the SCI module to prepare it for running.

    Best Regards,

    Allison

  • Hi Allison

    Your procedure resolved the interrupt problem.

    Now we are able to use UART at least even still we have the issue in (1).

    I'm so graceful. Thanks for your help.