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.

TMS320F28379D: SPI communication with 8 bits length

Part Number: TMS320F28379D

Hello,

I have TMS320F28379D which connects to a RTC module via SPI interface (4-wire).
The RTC module provides 8 bits length address and data.

When I configured the SPI with 16 bits (SPICHAR = 15) and used 16 bits read/write, the results are correct:

 spi_writeByte(0x0100); 
 second = spi_readByte(); //read register 0x01
However if the length of data is set to 8 (SPICHAR = 7), all the received data is wrong in the following two cases:

1.
spi_writeByte(0x01);            // seconds register read address
spi_readByte();                 // dummy read
spi_writeByte(0x01); 
second = spi_readByte(); //read register 0x01

2.
spi_writeByte(0x0100); 
second = spi_readByte(); //read register 0x01

Am I missing something?

Thanks,
HL

  • Hi Henry,

    For my application:
    SpiaRegs.SPICCR.bit.SPICHAR = 0xB; // 3:0 Character Length Control 12 bits

    This is how I transmitted 12 bits
    SpiaRegs.SPITXBUF = Vout1R << 4;

    This is how I got the slave data back.
    rdata_b = SpibRegs.SPIRXBUF & 0x0FFF;
  • Thanks for your reply.

    When the length is set to 8, The scope shows 8 clock pulses when a write is in progress, but there is no clocks for the following read.
    Do I have to do a dummy or next write in order to read? Or am I missing something in SPI master configuration?

    HL
  • The read serial bit stream is simultaneously clocked into the register with the transmit.clock

    After the data is transmitted the slave data has already shifted into the register.
    The read reads the contents of the register.

  • The master needs to send the address first and then the slave shifts out the corresponding value to the master.

    HL
  • Hi Henry

    Did you get your problem resolved or do you still have some problems?

    -Marlyn

  • Hi Marlyn,

    Yes, I send the address left-justified – 0x0100 for address 01.
    The problem is that the read value will come after 8 clock pulses, but SPI master provides only 8 clock pulses if the length is set to 8.

    Thanks,
    HL
  • Henry,
    For SPI, the master is the only one that supplies the clocks and it does so only during transmit.
    If your custom design is to transmit an address, then the slave receives it and it is in the pipeline to respond during the next transmit.

    Is your slave a 8 bit or 16 bit slave? normally it is the same as the master.

    For my application example, the address is always the same so I transmit out the value that was converted by the ADC in the uC that I use to graph the response and the slave transmits a voltage representation of the model's calculated output back to the uC during the same transmit.