Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

TMS320C6678: SPI can't run at 9.6khz speed which is triggered by timer

Genius 13655 points
Part Number: TMS320C6678

Hello Champs,


Customer uses the timer to control the SPI interface of C6678 to send data at a rate of 9.6k, send a 16bit data about every 104us, and receive a 16bit data at the same time. After receiving the data, it will do some processing on the data and generate the next data to be sent. The main frequency of the DSP is set to 1G, and the processing time must not exceed 104us. However, the program can run normally only when the SPI rate is configured to be above 60M, and the problem shown in the figure below will appear when the speed is less than 60M:

Or it prompted below error message when loading file. 



Below is the SPI configuration code
SPI_Data_Format SPIDataFormat =
{
.delayBetweenTrans_ns = 0,//两次传输之间的延迟
/*.ShifDirection = */SPI_MSB_SHIFT_FIRST,
/*.disable_CS_timing = */1,
/*.clockPolarity = */SPI_CLOCK_LOW_INACTIVE,
/*.clockPhase = */0,
// /*.clockSpeedKHz = */66000,
/*.clockSpeedKHz = */33000,
/*.wordLength = */16
};
SPI_Transfer_Param SPITransferParam =
{
SPI_CS_0, /*Chip select number*/
1, /*select one of the 4 SPI formats*/
SPI_CS_NO_HOLD, /*hold CS between multiple words*/
FALSE, /*Enable the delay counter at the end of the current transaction*/
// TRUE,
2 /*number of bytes per SPI word*/
};

Thanks
Regards
Shine

  • Shine,

    Let me experiment the SPI rate on C6678 EVM and get back....

    Meanwhile, please focus on the  "Main PLL and PLL Controller" and its clock division on the data sheet.

    Page no: 141

    • SYSCLK7: 1/6-rate clock for slow peripherals (GPIO, UART, Timer, I2 C, SPI, EMIF16, etc.) and sources the SYSCLKOUT output pin.

    For example, if the SYCLK is 1 GHz, the derived clock for SPI peripheral would be 1GHz/6 = 166 MHz.

    Regards

    Shankari G

  • Shine,

     I experimented C6678 EVM with 1 GHz as core clock.

    ---

    The following is the gel output. Notice the SYSCLK7 below as 200 MHz.

    ---- >We could drive the SPI clock by 200 MHz, if the core clock is 1 GHz.

    ------> If the core clock is 800 MHz, the SPI Clock could be derived at 133 MHz.

    C66xx_0: GEL Output: PLL in Bypass ...
    C66xx_0: GEL Output: PLL1 Setup for DSP @ 1200.0 MHz.
    C66xx_0: GEL Output: SYSCLK2 = 400.0 MHz, SYSCLK5 = 240.0 MHz.
    C66xx_0: GEL Output: SYSCLK8 = 18.75 MHz.
    C66xx_0: GEL Output: SYSCLK7 = 200.0 MHz.
    C66xx_0: GEL Output: PLL1 Setup... Done.

    Regards

    Shankari G

  • Hi Shankari G,

    Thanks for your great support.

    Customer doesn't use timer to generate SPI clock. He uses timer to generate an interrupt every 9.6k, the timer interrupt then triggers the SPI transmit. 

    Thanks
    Regards
    Shine

  • Shine,

    Let me know at what frequency, they drive the SPI clock? what is the value of their SYSCLK7?

    I hope they understand the SPI clock range with-respect-to the core frequency....

    Regards

    Shankari G

  • Hi Shankari G,

    Customer uses TI EVM. The CPU frequency is 1GHz, The SYSCLK7 SPI clock is divided by 6. 

    Thanks
    Regards
    Shine

  • Shine,

    OK.

    Would you please re-phrase the question with what they expect and what they got etc..

    Regards

    Shankari G

  • Hi Shankari G,

    Thanks for your support. 

    what they expect

    Customer is expecting to use 9.6k timer to trigger SPI to send data. 


    what they got etc

    The SPI can only send data correctly when the timer is set to 60M or above.

    9.6k and 60M are not for SPI clock, they are used to trigger SPI transfer every 9.6k or 60M. 


    Please feel free to let me know if there are some confusions.


    Thanks
    Regards
    Shine

  • Shine,

    What do they refer here by "60M" ?

    Regards

    Shankari G

  • Hi Shankari G,

    60M is configured in SPIFMTn.PERSCALE. It is said that it can be up to 66M. 60M is not SPI clock and not timer interrupt. The timer is 9.6k. 

    SPIFMTn.PERSCALE



    Thanks
    Regards
    Shine

  • Shine,

    IS 'M' in the 60M stands for Mega--> 10 to the power of 6 --> 1000000 --> 60000000.

    In the Spidataformat, the value is 66000 --> 66K-->66Kilo.

    ---

    It is still not clear to me, what do they refer as 60M. 

    Would you please expand "60M" ? 

    Regards

    Shankari G

  • Shine,

    ----

    Let me explain with the formula in the data sheet..

    ======================================

    SPI clock frequency = SPI module clock / ( prescale + 1 )

    ==> core frequency = 1 GHz.

    ====> SYSCLK7 = 1 GHz / 6 = 166666666 Hz ---> 166 MHz.

    =====> SPI Module Clock = 166 MHz.

    ===> Prescale ranges between 0 - FF ===> 0 - 255

    ========================================

    Maximum SPI clock frequency =  166666666 / ( 0 + 1) ----- > with the prescale value as 0

                                                        = 166 MHz 

    Minimum SPI clock frequency =  166666666 / ( 255 + 1) -----> with the pre-scale value as 255 

                                                        =  651041 Hz --> ~ 660000 Hz --->In your snapshot. It should have another zero as /*. clockSpeedKHz = */ 660000,

                                                        = 651 KHz. 

    As the minimum SPI clock frequency is 651 KHz, it cannot run at 9.6 KHz.

    ==========================================

    Please refer to this code for more clarity on SPI DATA format configuration.

    This code is part of processor SDK 6.3. 

    When I experimented, I could transfer the data into the SPI-NOR memory using this SPI-clock configuration, below.

    ---

    The SPI module clock is 166 MHz and the SPI Max frequency is 25 MHz

    And hence the prescale value = 5

    --

    In evmc665x_spi.c loated at  ---- > C:\ti\pdk_c665x_2_0_16\packages\ti\platform\evmc6657l\platform_lib\src\evmc665x_spi.c

    #define SPI_MODULE_CLK 166666666 /* SYSCLK7 = CPU_Clk/6 in HZ */
    #define SPI_MAX_FREQ 25000000 /* SPI Max frequency in Hz */

    ----

    /* setup format */
    scalar = ((SPI_MODULE_CLK / freq) - 1 ) & 0xFF;

    if ( cs == 0) {
    SPI_SPIFMT0 = (8 << CSL_SPI_SPIFMT_CHARLEN_SHIFT) |
                               (scalar << CSL_SPI_SPIFMT_PRESCALE_SHIFT) |
                               (CSL_SPI_SPIFMT_PHASE_DELAY << CSL_SPI_SPIFMT_PHASE_SHIFT) |
                               (CSL_SPI_SPIFMT_POLARITY_LOW << CSL_SPI_SPIFMT_POLARITY_SHIFT) |
                               (CSL_SPI_SPIFMT_SHIFTDIR_MSB << CSL_SPI_SPIFMT_SHIFTDIR_SHIFT);
    }else if ( cs == 1) {
    SPI_SPIFMT0 = (16 << CSL_SPI_SPIFMT_CHARLEN_SHIFT) |
                               (scalar << CSL_SPI_SPIFMT_PRESCALE_SHIFT) |
                               (CSL_SPI_SPIFMT_PHASE_NO_DELAY << CSL_SPI_SPIFMT_PHASE_SHIFT) |
                               (CSL_SPI_SPIFMT_POLARITY_LOW << CSL_SPI_SPIFMT_POLARITY_SHIFT) |
                               (CSL_SPI_SPIFMT_SHIFTDIR_MSB << CSL_SPI_SPIFMT_SHIFTDIR_SHIFT);
    }

    I hope this helps!

    Regards

    Shankari G