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.

TMS320F2808: Arduino Mega 2560- eZdsp TMS320F2808 SPI Communication via using Simulink- Embedded Coder

Part Number: TMS320F2808

Hi everyone,

I have a question related to SPI communication between Arduino Mega 2560 and TMS320F2808. I am using Arduino as Master(because it can not be used as Slave) and TMS320F2808 as Slave. I made all the necessary hardware level connections and I am sure it is working well. I simply send a word from Arduino to TMS and the model in Simulink simply consists of SPI Receive and SPI Transmit. I simply receive the data and transmit it back to Arduino. This is my purpose but unfortunately there are few problems that I encounter at this point:

-One or more than one bit is not transferred properly because it is lost. For instance if I send out the number 20 in unsigned integer format, it comes back as 10.

-If I send out a 1xN array, the order of the data is also changed. For instance if I send out [1 2 3 4 5] array, it comes back as [5 1 2 3 4]. 

These problems may be arising from several reasons. Please do not hesitate to reply even if you think your idea has nothing to do with this topic.

Look forward for opinions and help. Thanks.

  • Hi there,

    What is the length of each word being sent? if sending words that are less than 16 bits, the data must be left justified.
    have you observed the signals on an oscilloscope to tell if the data is being transmitted correctly?
    Can you store the received data into a buffer on the F2808 device to verify correctness being received after a burst of transfers?

    -Mark
  • Hi there,

    Each word's length is 16 bits(1 word).
    I do not have a chance to observe the signals on an oscilloscope.

    Actually I think my problem is about choosing the SPI mode(CPOL and CPHA). I have some ideas about how to choose it, but I can definitely use some help about it.
  • Çevikalp,

    You need to make the CPOL and CPHA match the device you are working with. Match the behavior and not the mode name. i.e.the C2000 mode 1 does not necessarily match what Mode 1 is on wikipedia or in other manufacturer's documentation. Ensure that the bits are being transmitted on the same clock edge between the devices, similarly match the receive edge between the devices.

    -Mark
  • Hi,

    For Ardunio boards - Mega 2560, Mega ADK, Uno, Nano 3.0, Micro and Leonardo uses 5V supply. Ensure that you use proper voltage level shift between Arduino and C2000 SPI pins for proper working of SPI. Arduino boards - Due and MKR 1000 uses 3.3V supply, you can connect them directly to C2000 boards and get the SPI running.

    And you need to ensure the SPI clock mode match properly between Arduino board and C2000 board.

    For example:

    If you select Mode 1 in Arduino Nano, you need to select options Rising edge, No delay in F28335 and if you select Mode 2 in Arduino Nano, you need to select options Falling edge, delay half cycle for F28335 to get the same SPI clock mode.
    Also ensure the Master and Slave is synchronized properly as discussed in https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/545531?c2000-as-spi-slave-message-synchronization. You can make use of SPI receive interrupt in F28335 to read the data.