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.

Data transfer through the SPI interface

Hello,

I am using OMAPL-137 DSP. 

I need transfer data coming from serial ADC through the SPI interface of DSP. I am going to use DMA in order to read data from the ADC. But I'm beginner in work with .

I read SPRUFM4I and SPRUH77A, but I have no idea how to start programming. Could you hekp me and tell me steps which I have to do ?

Can I use any CSL or similar packages (without Linux) ? Or I have to configure the SPI directly through registers ?

Thank you !

  • Andrey,

    The examples for C674x are based on DSP/BIOS drivers: PSP (platform support package). Getting started with C6747 DSP on the OMAPL137 is described here:

    http://processors.wiki.ti.com/index.php/Getting_Started_Guide_for_C6747

    A CSL package that  was generally supported on older devices consisted of register and functional CSL. So If you are looking for register CSL kind of examples, you can find that under C:\Program Files\Texas Instruments\pspdrivers_xx_xx_xx\packages\ti\pspiom\cslr\evm6747\examples.

    There is a SPI example in the PSP package which configures the peripheral in master mode but you will need SPI in Slave mode to read data from the ADC.

    Regards,

    Rahul


  • Thank you Rahul !

    I try to read data from ADC in slave mode through SPI1. However I faced with problems. I set registers:

    /* First reset the SPI chip                                               */
        spiRegs->SPIGCR0 = CSL_FMK(SPI_SPIGCR0_RESET, CSL_SPI_SPIGCR0_RESET_IN_RESET);

        /* now bring the chip out of reset state                                  */
        spiRegs->SPIGCR0 = CSL_FMK(SPI_SPIGCR0_RESET, CSL_SPI_SPIGCR0_RESET_OUT_OF_RESET);

        /* enable the CLKMOD and MASTER bits in the SPI global control reg        */
        spiRegs->SPIGCR1 |=  CSL_FMK(SPI_SPIGCR1_MASTER,0x00)                    // 0x00 - Slave !
                                                 | CSL_FMK(SPI_SPIGCR1_CLKMOD,0x00);                  // 0x00 - Slave !

         /* enable the pins so that they are used for the SPI interface(Multiplex) */
        spiRegs->SPIPC0  = CSL_FMK(SPI_SPIPC0_CLKFUN ,0x01)
                                             | CSL_FMK(SPI_SPIPC0_SOMIFUN ,0x01)
                                             | CSL_FMK(SPI_SPIPC0_SIMOFUN ,0x01);
                                    

        /* enable the pins so that they are used for the SPI interface(PC1) */
       spiRegs->SPIPC1  =
                                     CSL_FMK(SPI_SPIPC1_SOMIDIR ,0x01)
                                     | CSL_FMK(SPI_SPIPC1_SIMODIR ,0x00)
                                     | CSL_FMK(SPI_SPIPC1_CLKDIR  ,0x00)
                                     | CSL_FMK(SPI_SPIPC1_SCS0DIR0 ,0x00) ;


        /* configure the data format in SPIFMT                                    */
        spiRegs->SPIFMT[0] = CSL_FMK(SPI_SPIFMT_CHARLEN,SPI_NUM_OF_TXBITS)
                                                | CSL_FMK(SPI_SPIFMT_PRESCALE,0x02);

        /* set the preconfigure data format as 0 which is already set above       */
        spiRegs->SPIDAT1 = CSL_FMKT(SPI_SPIDAT1_DFSEL,FORMAT0);

        spiRegs->SPIINT0 = CSL_FMKT(SPI_SPIINT0_RXINTENA,DISABLE);

        spiRegs->SPIGCR1 |=  CSL_FMK(SPI_SPIGCR1_ENABLE,0x01);

    Reading data:

    #define SPI_NUM_OF_TXBITS   8
    #define SPI_NEW_DATA_NO   0x01

    CSL_SpiRegsOvly  spiRegs=(CSL_SpiRegsOvly)CSL_SPI_1_REGS;

    while ((CSL_FEXT(spiRegs->SPIBUF,SPI_SPIBUF_RXEMPTY))   == SPI_NEW_DATA_NO);

                test = (CSL_FEXT(spiRegs->SPIBUF,SPI_SPIBUF_RXDATA));

    No data is received ! I cannot find error in my code. How to set OMAPL137 in Slave mode ?