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: FSI TX and RX buffer read issue

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE

I adapted the fsi_ex8_ext_p2pconnetion_Xx projects to work on our custom board containing two TMS320F28388D's.  I want to use the FSI for inter-chip coms.  From the tx chip, I send a known fixed pattern (0x1,0x2,0x3,0x4,0x5,0x6) and not the increasing pattern used by default.

On the receiving side I have the following rx_isr:

uint16_t rxDataArray[16];

__interrupt void fsiRxInt1ISR(void)
{
    rxEventSts = FSI_getRxEventStatus(FSIRXA_BASE);

    fsiRxInt1Received = 1U;

    //
    // Increment number of data frames received
    //
    if((rxEventSts & FSI_RX_EVT_DATA_FRAME) != 0)
    {
        dataFrameCntr++;
        FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, 0);

        FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
    }


    //
    // Clear the interrupt flag and issue ACK
    //
    FSI_clearRxEvents(FSIRXA_BASE,rxEventSts);
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP4);
}

But looking at the array it always has an offset

If I understand correctly the rxbuffer should be a circular buffer and because I set the nword length to 6 it should loop the circ buf every 6 words, correct?  And because I call the FSI_setRxBufferPtr function and set it to 0, it should always receive the first byte to position 0 correct?  What am I missing?

Kind regards

EDIT:

I don't think that the clock settings should affect the FSI in a manner that would cause this issue, but I also changed device.h to use new cristal

//
// 18.432MHz XTAL on controlCARD. For use with SysCtl_getClock() and
// SysCtl_getAuxClock().
//
#define DEVICE_OSCSRC_FREQ          18432000U

//
// Define to pass to SysCtl_setClock(). Will configure the clock as follows:
// PLLSYSCLK = 18.432MHz (XTAL_OSC) * 54 (IMULT) / (1 (REFDIV) * 5 (ODIV) * 1(SYSDIV))
//
#define DEVICE_SETCLOCK_CFG          (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(54) | \
                                      SYSCTL_REFDIV(1) | SYSCTL_ODIV(5) | \
                                      SYSCTL_SYSDIV(1) | SYSCTL_PLL_ENABLE | \
                                      SYSCTL_DCC_BASE_1)

//
// 200MHz SYSCLK frequency based on the above DEVICE_SETCLOCK_CFG. Update the
// code below if a different clock configuration is used!
//
#define DEVICE_SYSCLK_FREQ          ((DEVICE_OSCSRC_FREQ * 54) / (1 * 5 * 1))

//
// 50MHz LSPCLK frequency based on the above DEVICE_SYSCLK_FREQ and a default
// low speed peripheral clock divider of 4. Update the code below if a
// different LSPCLK divider is used!
//
#define DEVICE_LSPCLK_FREQ          (DEVICE_SYSCLK_FREQ / 2)

//
// Define to pass to SysCtl_setAuxClock(). Will configure the clock as follows:
// AUXPLLCLK = 20MHz (XTAL_OSC) * 50 (IMULT) / (2 (REFDIV) * 4 (ODIV) * 1(AUXPLLDIV) )
//
#define DEVICE_AUXSETCLOCK_CFG       (SYSCTL_AUXPLL_OSCSRC_XTAL | SYSCTL_AUXPLL_IMULT(50) |  \
                                      SYSCTL_REFDIV(2U) | SYSCTL_ODIV(4U) | \
                                      SYSCTL_AUXPLL_DIV_1 | SYSCTL_AUXPLL_ENABLE | \
                                      SYSCTL_DCC_BASE_0)

//
// 125MHz AUXCLK frequency based on the above DEVICE_AUXSETCLOCK_CFG. Update
// the code below if a different clock configuration is used!
//
#define DEVICE_AUXCLK_FREQ          ((DEVICE_OSCSRC_FREQ * 50) / (2 * 4 * 1))

  • Hi Christo,

    If I understand correctly the rxbuffer should be a circular buffer and because I set the nword length to 6 it should loop the circ buf every 6 words, correct?  And because I call the FSI_setRxBufferPtr function and set it to 0, it should always receive the first byte to position 0 correct?  What am I missing?

    Your understanding is correct. If you didn't call 'FSI_setRxBufferPtr(FSIRXA_BASE, 0U)' then the subsequent frame of 6 words would start at position 7 in the buffer.

    I think the issue is that the RX buffer pointer is getting reset to zero before the full 6 words are moved into your data array. You can quickly test this by adding some delay in the portion below:

        //
        // Increment number of data frames received
        //
        if((rxEventSts & FSI_RX_EVT_DATA_FRAME) != 0)
        {
            dataFrameCntr++;
            FSI_readRxBuffer(FSIRXA_BASE, rxDataArray, nWords, 0);
            
            //
            // ADD DELAY HERE!
            //
    
            FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
        }

    Also using the memory browser in CCS to check the FSI RX Buff location to see if the correct data is being received there would be good.

    Best,

    Kevin

  • Hi Kevin

    I added a delay with no success.  The original code had the reset of the RX buf pointer in the main loop and not in the ISR.  I moved it to the ISR to try and make sure it was not the issue.  I moved it back to main loop 

        //
        // Now, start transmitting data frames
        //
        FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
        while(1)
        {
            while(fsiRxInt1Received != 1U);
    
            //
            // Re-initialize flags and buffer pointer before next transmission
            //
            fsiRxInt1Received = 0U;
            FSI_setRxBufferPtr(FSIRXA_BASE, 0U);
        }

    where the fsiRxInt1Received variable is set to 1 in the ISR and to 0 here.  The result is exactly the same.  

    Looking at the memory browser the data order is the same:

    Kind regards and thank you for the feedback so var

    EDIT:

    Just to confirm the tx side, the memory map is as follows:

    EDIT 2:

    Sending incremental data shows the following:

    That means that it's not old data in index 0 and 1.  The data was for this frame started to read into index 2 and looped back to 0.  Hope that makes sense...

  • Hi Christo,

    I still think it's something wrong with the RX buffer pointer being set to zero at an incorrect time causing the data misalignment. That's the only thing I can think of causing this behavior. Or maybe it's starting at bufPtrOff = 2 initially.

    Can you try testing with the example projects below that are in C2000WARE location: C:\ti\c2000\C2000Ware_4_01_00_00\driverlib\f2838x\examples\c28x\fsi

    • fsi_ex16_daisy_handshake_lead
    • fsi_ex16_daisy_handshake_node

    Please set the below define to zero as well when testing.

    #define FSI_DMA_ENABLE              0

    Best,

    Kevin

  • Hi Kevin

    I had a quick test and it seems to work correctly.  I'll have to spend some time tomorrow to try and figure out why they differ. I will keep you updated.

    Christo

  • Hi Christo,

    OK, that's good. Yes, please let me know what you find.

    Best,

    Kevin

  • Ok, this took me longer than I hoped!  

    I was convinced the problem was on the receiving side, but in the end, it was on the sending side...  You were on the correct track Kevin.  The problem was the fact that the sending side called FSI_setTxBufferPtr(FSITXA_BASE, 0U); in the main loop.  The lead-node example moved FSI_setTxBufferPtr(FSITXA_BASE, 0U); from main loop to the ISR.  When I did the same, the problem went away.

    Kind regards