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.

c5505 spi doubt

Other Parts Discussed in Thread: TMS320C5505

Hi, 

 Am using tms320c5505 custom board with xds100 usb v1 emulator. now i want use spi protocol from tms320c5505 . i dont how to mux it from gpio ., and also need some spi initialize coding ., could you please provide me ?

  • Hi,

    Your request is taken up for action and will be answered as soon as possible.

    Thanks & regards,
    Sivaraj K

  • Sivaraj Kuppuarj,

    i want use the following pins from tms320c5505

    CLK - N10 - GP18

    CS0 - P11 - GP19

    RXD - N11 - GP20

    TXD - P12 - GP27

    External Bus Selection Register[0x1C00]  = 0x3000;  am i right in cofiguration?? i have choosen the PP mode 3.  is it right ???????????

    need any SPI initalize code ., am using spi dac

  • Hi,

       Pin mapping is correct. Your EBSR configuration looks fine for PP mode 3.

        You could refer to SPI CSL example, by downloading and installing CSLs from the below link.

       http://www.ti.com/tool/sprc133

       Hope this helps.

    Regards

     Vasanth

      

      

  • Vasantha, 

        am not able to access spi dac., kindly my coding and tell about if i made any mistakes. i just done PPmode3 and writing data to SPIDAT1  and probe the spi lines, not even i got a clock. 

    void SPI_Init()
    {
    SYS_EXBUSSEL = 0x3000; // Enable SPI mode - 3 bus
    SPICDR = 0x0008; // SPI_CLK = (SPI_IP FREQ/(CLKDIV+1))
    SPICCR = 0x8000; // Enable the SPI_CLK
    SPICMD1 = 0x000F; // 16 character, FLEN+1, no interrupts
    SPICMD2 = 0x00F2; // CLEN, type of transaction
    }


    /****************************/
    /* SPI 16 bit Data to Dac */
    /****************************/
    void SPI_Write(unsigned short Data)
    {
    unsigned long receive; // 32 bit

    Data = ( 0x3000 | Data );

    /* Clear any old data */
    receive = SPIDAT1;
    receive |= (16<<SPIDAT2);

    // Wait for transmit ready - check busy bit
    while((SPISTAT1 & 0x0001)==1);
    // Write 1 byte
    SPIDAT1 = Data;
    // Wait for Character transfer complete
    // while((SPISTAT1 & 0x0002)==0);

    // Wait for receive data ready
    /* Read 1 byte */
    receive = SPIDAT1;
    receive = (16<<SPIDAT2);
    }

    Many Thanks,

    Thiyagarajan.S

  • Hi,  

       All the register i configuring perfectly for C5505 SPI0 , using the pins which i said in previous post. i uploaded the code and screenshot of ccs. please check and tell., continuously am writing some values in SPIDAT register and checking in the SPI lines not getting any pulses.... i Think my SPI i not enabled.. please check this and solve this ,.

    void main( void )
    {
    /* Initialize BSL */
    USBSTK5515_init( ); // Enable clock to all peripherals
    SPI_Init(); // Initialize the SPI0

    sampt = 1/sampf;
    nsamp = sampf/inpf;
    DAC_CS_HIGH();

    while(1)
    {
    for(count=0;count<nsamp;count++)
    {
    teta = (2 * PI * inpf * sampt * count);
    value = sin(teta)*2048;
    Sent_to_SPI(value);
    }
    }
    }

    void Sent_to_SPI(unsigned int Value)
    {
    Value = (Value & 0x0FFF);
    SPI_Write(Value);
    }

    void SPI_Init()
    {
    volatile Int16 looper;

    SYS_EXBUSSEL = 0x5000; // Enable GPIO18,19,20,27 mode - 2 bus , for SPI mode 3
    SYS_PRCNTR = 0xFFFF; // Periperla s/w RST counter Register PSRCR
    SYS_PRCNTRLR = 0x00FF; // Peripheral Reset Control Register PRCR
    SPICDR = 0x0000;
    SPICCR = 0x0000;
    SPIDCR1 = 0x0000;
    SPIDCR2 = 0x0000;
    SPICMD1 = 0x0000;
    SPICMD2 = 0x0000;
    SPISTAT1 = 0x0000;
    SPISTAT2 = 0x0000;
    SPIDAT1 = 0x0000;
    SPIDAT2 = 0x0000;

    for(looper = 0; looper < 100; looper++) {;}


    SPICCR = (1<<15)|(0<<14); // Enable the SPI_CLK, RST release
    delay_ms(10);

    SPICDR = 0x0019; // SPI_CLK = (SPI_IP FREQ/(CLKDIV+1))
    SPICMD2 = (0<<12)|(15<<3)|(3<<0); // select CS0, CLEN = 15 - word length, write cmd
    SPICMD1 = (1<<14)|(1<<0); // frame length - 2 ,FLEN+1, no interrupts
    SPIDCR1 = (0<<3)|(0<<2)|(0<<1)|(0<<0);
     

    }

    /****************************/
    /* SPI 16 bit Data to Dac */
    /****************************/
    void SPI_Write(unsigned int Data)
    {
    Data = ( 0x3000 | Data );
    // Wait for transmit ready - check busy bit
    while((SPISTAT1 & 0x0001)==1);
    SPIDAT1 = Data;
    // Wait for Character transfer complete
    //while((SPISTAT1 & 0x0002)==0);
    }

      

  • Have you been able to run the examples in CSL?

  • Hi,

      Can you ensure the below initialization steps is taken care.

    •  Ensure the SPI is out reset by setting SPI_RST=0 in the peripheral reset control register (PRCR).
    •  Enable the SPI input clock by setting SPICG to 0 in the peripheral clock gating configuration register (PCGCR1).   (By default clk should be enabled but cross check... again)
    •  Set CLKEN = 0 to disable SPI_CLK. The CLKEN bit is part of SPICCR .
    •  Set CLKDV in SPICDR to provide the appropriate SPI_CLK frequency. Note that for proper device operation, CLKDV must be greater than or equal to 3 .
    •  Set CLKEN = 1 to enable SPI_CLK.

    Your code depicts that you tried by setting EBSR parallel mode to both 3 and 5 (2nd post of your code). This should be ok.

    Also as suggest in the earlier post you could refer to SPI CSL example for initialization sequence / Run those examples. This would help ease your debug.

    Regards

     Vasanth

  • Steve , 

    i couldnt able to use CSL example projects. after importing projects from the cls location, am getting the folllowing error:


    **** Build of configuration Debug for project COMMON_ROOT ****

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake -k all
    'Building file: ../csl_i2c_ioExpander.c'
    'Invoking: Compiler'
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/bin/cl55" -v5505 -g --define="_DEBUG" --include_path="C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include" --include_path="C:/c55_lp/c55_csl_3.04/c55xx_csl/inc" --include_path="C:/Users/user/Desktop/C5505_SPI/COMMON_ROOT/Debug" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/bios/include" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/rtdx/include/c5500" --include_path="/packages/ti/xdais" --include_path="/src" --include_path="/inc" --include_path="" --diag_warning=225 --large_memory_model --ptrdiff_size=16 --algebraic --asm_source=algebraic --preproc_with_compile --preproc_dependency="csl_i2c_ioExpander.pp" "../csl_i2c_ioExpander.c"
    ERROR: option --include_path is missing its parameter 'dir'

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake: *** [csl_i2c_ioExpander.obj] Error 1
    'Building file: ../csl_spi_example.c'
    'Invoking: Compiler'
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/bin/cl55" -v5505 -g --define="_DEBUG" --include_path="C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include" --include_path="C:/c55_lp/c55_csl_3.04/c55xx_csl/inc" --include_path="C:/Users/user/Desktop/C5505_SPI/COMMON_ROOT/Debug" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/bios/include" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/rtdx/include/c5500" --include_path="/packages/ti/xdais" --include_path="/src" --include_path="/inc" --include_path="" --diag_warning=225 --large_memory_model --ptrdiff_size=16 --algebraic --asm_source=algebraic --preproc_with_compile --preproc_dependency="csl_spi_example.pp" "../csl_spi_example.c"
    ERROR: option --include_path is missing its parameter 'dir'

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake: *** [csl_spi_example.obj] Error 1
    'Building file: ../spi_eepromApi.c'
    'Invoking: Compiler'
    "C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/bin/cl55" -v5505 -g --define="_DEBUG" --include_path="C:/Program Files/Texas Instruments/ccsv4/tools/compiler/c5500/include" --include_path="C:/c55_lp/c55_csl_3.04/c55xx_csl/inc" --include_path="C:/Users/user/Desktop/C5505_SPI/COMMON_ROOT/Debug" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/bios/include" --include_path="C:/Program Files/Texas Instruments/bios_5_41_02_14/packages/ti/rtdx/include/c5500" --include_path="/packages/ti/xdais" --include_path="/src" --include_path="/inc" --include_path="" --diag_warning=225 --large_memory_model --ptrdiff_size=16 --algebraic --asm_source=algebraic --preproc_with_compile --preproc_dependency="spi_eepromApi.pp" "../spi_eepromApi.c"
    ERROR: option --include_path is missing its parameter 'dir'

    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake: *** [spi_eepromApi.obj] Error 1
    C:\Program Files\Texas Instruments\ccsv4\utils\gmake\gmake: Target `all' not remade because of errors.
    Build complete for project COMMON_ROOT

    Please , if you provide separate spi example with complete workspace folder with metadata, so that i can check directly. then i do my self coding ., kindly help for this .. 

  • Hi,

    Suggest you to follow the steps mentioned in the CSL installation guide. The installation guide resides in the below mentioned folder, it provides step by step information on building and running the CSL example. 

      "\c55_csl_3.04\c55xx_csl\C55XCSL-LOWPOWER-3.04.00_Installation_Guide.pdf"

    Also, Hope you have confirmed on steps that we mentioned prior to this post.

    Regards

     Vasanth