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.

Sample code to read/write array with SPI ?

Other Parts Discussed in Thread: TMS320F28035

 This is my first time using SPI with TMS320F28035. I am trying to read/write an array over SPI. Does SPI allows us to send only single byte or there could be an N-Byte operation? I am interfacing a Microchip's ENCX24J600 ethernet controller

What I am trying to do is in Mode 0,0 send and receive N bytes of data  .  For example lets send  4 bytes of data and receive 4 bytes of data in full duplex operation :

1-SPISTE goes low

2-SPICLK runs with the required baud rate 8*16 times while SPISTE is low 

3- SPISIMO starts to put 4*16 bits of data

4. When SPISIMO is done then SPISIMO starts to put 4*16 bits of data

5. SPISTE goes high

It would be very great if someone could explain with a sample code to read an array or to write an array. Of course if this is possible with TI dsp. I believe anything is possible with TI products..



  • Kerem,

    I send out 3 8 bit packets to an SPI device using the following code:

    //*****************************************************************************

    // Transmit a character from the SPI to DAC in 3 8 bit packets

    //*****************************************************************************

    void

    spiXmit(SPIDATA spiXmitData)

    {

    extern int xmitCounter;

    AssertSlaveSelect(spiXmitData.slaveInstance);

    SPIIntFlag = 1;

    SpiaRegs.SPIDAT = spiXmitData.firstPacket << 8;   //shift data to the left in spi register

    while (SPIIntFlag)

    {

    };

    SPIIntFlag = 1;

    SpiaRegs.SPIDAT = spiXmitData.secondPacket << 8;   //shift data to the left in spi register

    while (SPIIntFlag)

    {

    };

    SPIIntFlag = 1;

    SpiaRegs.SPIDAT = spiXmitData.thirdPacket << 8;   //shift data to the left in spi register

    while (SPIIntFlag)

    {

    };

    ClearSlaveSelect(spiXmitData.slaveInstance);

    }

    I do not recive back data as my device is only echos. I need to send 24bits while CS stays low and early on (if i recall correctly) CS would toggle after 16 bits went out when using the FIFO ,so i use a GPIO as a CS to keep it low until i am done sending data. Since it started working i did not go back and try to use the FIFO to improve timing.

    Hoepfully this kind of helps.