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.

Problem SPI TMS320F28069PZA

Other Parts Discussed in Thread: TMS320F28069, CONTROLSUITE

Hello,

I have a problem with my MCU TMS320F28069PZA (piccolo controlstick). I use it in slave mode and i can only send data just after read it. I don't understand why because SPI work in full duplex so normally i can send data when i want. The master is a PIC, and it work perfectly.

 

Code example:

        while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) { }
        test = SpiaRegs.SPIRXBUF&0xFF;//read

        SpiaRegs.SPITXBUF='P';/write

        while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) { }
        test = SpiaRegs.SPIRXBUF&0xFF;//read

That's work but i want to do that:

        SpiaRegs.SPITXBUF='P';//write

        while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) { }
        test = SpiaRegs.SPIRXBUF&0xFF;//read

        SpiaRegs.SPITXBUF='O';//write

        while(SpiaRegs.SPISTS.bit.INT_FLAG !=1) { }
        test = SpiaRegs.SPIRXBUF&0xFF;//read

With this code no data is send.

My question is why the slave don't want to send data every time???

 

  • That is the nature of being a slave on the SPI interface.  If the TMS320F28069 is not configured as a master SPI interface, then it is reliant on the external host processor which is the master SPI device to generate the serial bit clock and timing.

    If the external host processor doesn't initiate a transfer by generating a serial bit clock and therefore "send" data to the TMS320F28069 which then receives this data, the TMS320F28069 can not arbitrarily start sending its own data.

    If you want the TMS320F28069 to send the 'P' on its own, either configure the TMS320F28069 to be the master, or use an asynchronous mechanism like a UART which has independency between the Transmit and Receive paths.

  • Hello,

    First, Thank you for your answer. I make a representation of my problem:

    The SPI clock come from the master.

    Case 1 : it's for the first example

    Case 2: for the second

    Case 3: that's what i want

     

    I can't have the case 3 with TMS320F28069 in slave mode?

  • Perhaps I need to take a step back in understanding  your setup.

    Are you intending to configure the TMS320F28069 in SPI slave mode?  With SPICLK and SPIMOSI as inputs and SPIMISO as an output?

    If so, then before the SPICLK starts toggling, you will need to make sure the TMS320F28069 is configured and the SPITXBUF has been written with your character 'O'.

  • Yes, the TMS320F28069 is in SPI slave mode, SPICLK, SPIMOSI are inputs and SPIMISO ouput.

    Master send data every time and i can read it without problem with TMS320F28069.

    The TMS320F28069 is configured correctly, i think, because i send data half the time with the first example. My system work slowly so the TMS320F28069 has the time to write into SPITXBUF.

    Pieces of program are implanted in loop and run forever.

    My problem is, i can't send data every time with my TMS320F28069 in slave mode. And i use function see in the controlsuite.

    If i configure the TMS320F28069 in master, i can send data every time.

     

  • One problem with your code may be that your interface is configured as 16 bits but you are transmitting 8 bit characters.

     - First configure the SPI interface to work with 8 bit characters (otherwise your receive int will occur every 16 edges of the SPICLk),

     - To transmit 8 bits you need to left align your writes into the TXBUF, i.e. SpiaRegs.SPITXBUF = 'C' << 8;