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.

TMS320F28388D: How to clear and deactivate FIFO of SCI before SysBios initialization

Part Number: TMS320F28388D
Other Parts Discussed in Thread: SYSBIOS

Hello,

I've a program that start with a "configuration" mode, where SysBios is not initialized and functional application is still not started, in this configuration I use SCI in FIFO mode to perform some debug/configuration.

My code of SCI FIFO initialize and deinitialize in this way:

void idSCIinitFIFO(void)
{
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    Interrupt_initModule();
    
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    Interrupt_initVectorTable();
    
    Interrupt_register(INT_SCIA_RX, sciaRXFIFOISR);
    Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);
    
    SCI_resetChannels(SCIA_BASE);
    SCI_enableFIFO(SCIA_BASE);

    SCI_enableInterrupt(SCIA_BASE, (SCI_INT_RXFF | SCI_INT_TXFF));
    SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXERR);
    
    SCI_setFIFOInterruptLevel(SCIA_BASE, SCI_FIFO_TX0, SCI_FIFO_RX1);
    SCI_performSoftwareReset(SCIA_BASE);
    
    SCI_resetTxFIFO(SCIA_BASE);
    SCI_resetRxFIFO(SCIA_BASE);
    
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    EINT;
    ERTM;
}

void idSCIdisableFIFO(void)
{
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    // To disable if generates problems, actually deactivated in case is activated during initialization
    DINT;
    DRTM;
    
    SCI_disableInterrupt(SCIA_BASE, (SCI_INT_RXFF | SCI_INT_TXFF | SCI_INT_TXRDY | SCI_INT_RXRDY_BRKDT | SCI_INT_RXERR));
    
    SCI_resetTxFIFO(SCIA_BASE);
    SCI_resetRxFIFO(SCIA_BASE);
    
    SCI_disableFIFO(SCIA_BASE);
    
    Interrupt_disable(INT_SCIA_RX);
    Interrupt_disable(INT_SCIA_TX);
    
    Interrupt_unregister(INT_SCIA_RX);
    Interrupt_unregister(INT_SCIA_TX);
    
    SCI_performSoftwareReset(SCIA_BASE);
    
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
    
    EINT;
    ERTM;
}

Seems that there's leftovers since when I SysBios_Start() I've an interrupt unhandled that rises.

There's something that I miss to clear before start SysBios? I'd really like to avoid to add this interrupt to SysBios since it's really outside application.

  • Hello,

    Due to US holiday, please expect a response by 20th February.

    Thanks & Regards,

    Sinchita

  • Hi Yaroslav,

    By "unhandled" interrupt, do you mean that the interrupt flag is pending in the PIE so that when SysBios_Start() is called, it tries to branch to an ISR (even though you are clearing it with Interrupt_clearACKGroup)? Is this for a receive or transmit interrupt? And are you using the TXENA or RXENA bit to stop data from going to/past the shift register? Do you know how much data is "leftover"?

    Best Regards,

    Allison

  • Two interrupt are registered, RX and TX with two levels RX when 1 Byte received and TX when Empty.

    I unregister and disable both. Then clear FIFO and ACK if interrupts are left over.

    In this situation I SHOULD have initial condition. But there's something that isn't correctly repristinated and when SysBios starts it have an unregistered interrupted from vector 97 (sciTX).

  • Hi Yaroslav,

    You should be able to flush the FIFO registers using RXFIFO Reset and TXFIFO Reset as you have, and with the interrupts disabled there shouldn't be any way for SCI to be triggering an interrupt when sysbios starts. How are you checking the source of the unregistered interrupt?

    Can you try putting a breakpoint at SysBios_Start() and check the PIE and interrupt-related CPU registers to see if anything is incorrectly enabled or if any flags are still set at that point?

    Best Regards,

    Allison

  • There's an overwrite of SYSBIOS vector table when this functions are called:


    Interrupt_initVectorTable();
    Interrupt_register(INT_SCIA_RX, sciaRXFIFOISR);
    Interrupt_register(INT_SCIA_TX, sciaTXFIFOISR);
    Interrupt_unregister(INT_SCIA_RX, sciaRXFIFOISR);
    Interrupt_unregister(INT_SCIA_TX, sciaTXFIFOISR);

    SYSBIOS vector table is defined inside generated app_xxx.c and loaded into memory.

    /*
    * ======== ti.sysbios.family.c28.Hwi TEMPLATE ========
    */
    
    
    extern Void _c_int00(Void);
    extern Void ti_sysbios_family_c28_Hwi_dispatchPie(Void);
    extern Void ti_sysbios_family_c28_Hwi_dispatchTable(Void);
    extern Void ti_sysbios_family_c28_Hwi_unPluggedInterrupt__I(Void);
    
    /* Interrupt vector table. This will be copied to 0xd00 at boot time. */
    const UInt32 ti_sysbios_family_c28_Hwi_vectors[] = {
    
    HERE
    
    }

    Is there a way to solve this?

    I've think about a backup of this vector and restoration but I don't know if there's side process that may corrupt something else.

  • Hi Yaroslav,

    Can you read the SCI interrupt entries in the vector table before you call Interrupt_register() and save them to variables (basically backing up the BIOS dispatcher ISR)? Then when you are disabling the interrupts, instead of calling Interrupt_unregister(), you can call Interrupt_register() and pass it the vector table entry that you had saved earlier to restore the BIOS ISR.

    Best Regards,

    Allison

  • This solution partially works. Application doesn't stuck inside unhandled interrupt anymore and interrupts correctly works except for IPC interrupts that doesn't get called.

    I've checked and also IPC is inside dispatcher vector of SysBios , so it's correctly repristinated but something doesn't work correctly.

    Do you have advices to how repristinate also IPC?

  • Hi Yaroslav,

    Glad to hear some progress has been made. To clarify, when you say that the IPC interrupts don't work, is there a specific issue you are seeing or stopping point in the program? Are you receiving any other error in CCS?

    Best Regards,

    Allison

  • The program on CM enters into a waiting routine for IPC assert from CPU1 , on CPU1 is raised an interrupt to clear this flag. Usually this routine works.

  • Hi Yaroslav,

    Is it that the interrupt is not being called at all? (i.e. if you set a breakpoint in the interrupt, it the program doesn't hit the ISR). And are you able to verify that the IPC flag is asserted?

    Also wanted to double check you are acknowledging (ACK) the interrupt in the PIE?

    Best Regards,

    Allison