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.

TMS320F280039C: TMS320F280039C SPI Master configuration.

Part Number: TMS320F280039C
Other Parts Discussed in Thread: SYSCONFIG

Hi All,

i am interfacing two  TMS320F280039C launchpad boards. one as master & another as slave.

i need master configuration 1 byte receive interrupt . no loopback , 500Kbps.

this is my current configuration generated from sysconfig tool: 

void SPIA_MASTER_init()

{
SPI_disableModule(SPIA_MASTER_BASE);
SPI_setConfig(SPIA_MASTER_BASE, DEVICE_LSPCLK_FREQ, SPI_PROT_POL0PHA0,
SPI_MODE_MASTER, 500000, 8);
SPI_disableFIFO(SPIA_MASTER_BASE);
SPI_clearInterruptStatus(SPIA_MASTER_BASE, SPI_INT_RX_DATA_TX_EMPTY);
SPI_enableInterrupt(SPIA_MASTER_BASE, SPI_INT_RX_DATA_TX_EMPTY);
SPI_disableLoopback(SPIA_MASTER_BASE);
SPI_setEmulationMode(SPIA_MASTER_BASE, SPI_EMULATION_FREE_RUN);
SPI_enableModule(SPIA_MASTER_BASE);
}

  • Rahul,

    (1) 8 represent datawidth - The dataWidth parameter defines the width of the data transfers and can be a value between 1 and 16, inclusive.

            In your cause you are configuring SPI to have byte by byte transaction.

    (2) SPI_INT_RX_DATA_TX_EMPTY - When you choose this option SPI interrupt is generated by a data received (or) when transmit operation is complete

    (3) SPI_setEmulationMode(SPIA_MASTER_BASE, SPI_EMULATION_FREE_RUN); - You can configure SPI to stop transaction on a debugger halt. In your case, you have configured SPI not to stop SPI transaction on debugger halt. No issues with this configuration.

    Regards,

    Manoj

  • Hi Manoj , Thanks for the information. 

    one more question : My Master Receive interrupt is trigger if i call SPI_writeDataBlockingNonFIFO(SPIA_BASE,TxData_u16[i] );. i get same data in receive interrupt which i am transmitting Rx_byte = SPI_readDataNonBlocking(SPIA_BASE);

    Is there any API in TMS320F280039C to get Master receive interrupt only if actual slave data received?

  • Rahul,

    Just to be clear. Here is my understand of what you are trying to do

    Board1.SPIA is Controller (Master)

    Board2.SPIA is Peripheral (Slave)

    one more question : My Master Receive interrupt is trigger if i call SPI_writeDataBlockingNonFIFO(SPIA_BASE,TxData_u16[i] );. i get same data in receive interrupt which i am transmitting Rx_byte = SPI_readDataNonBlocking(SPIA_BASE);

    Board1.SPIA initiates are transaction when you execute "SPI_writeDataNonBlocking(SPIA_BASE, 1 byte data to be transmitted to Board2.SPIA);". This should transmit 1 byte of data to Board2.SPIA generating an SPI interrupt on Board2. SPIA. In board2.SPIA ISR, you read the contents in SPI RX buffer (read contents should be what board1.SPIA transmitted), then board2.SPI can execute SPI_writeDataNonBlocking(SPIA_BASE, 1 byte data to be transmitted to Board1.SPIA). This should trigger SPI interrupt on Board1.SPIA where you can read what board2.SPIA transmitted.

    Regards,

    Manoj

  • hi Manoj,

    you above observation is right. 2 boards Master & slave  using SPIA.

    but Master is  getting same data in receive interrupt which Master is transmitting. but master should only get receive interrupt only if slave is transmitting data. 

  • Rahul,

    If your peripheral (slave) SPI isn't ready with data to be transmitted, then peripheral (slave) SPI is re-transmit what it received. To avoid that, make sure SPI slave has the data to be transmitted in SPITXBUF before master SPI initializes transaction.

    Regards,

    Manoj

  • hi manoj ,

    below are my requirement :

    1. SPIA as master.

    2. Baud rate : 500kbps

    3. Receive interrupt 1 byte (do not want transmit interrupt).

    4. SPI Mode 0: Polarity 0 Phase 0.

    Please check below configuration & let me know where i should modify.

  • Above configuration does look right for what you are trying to do.

    Regards,

    Manoj

  • Root cause of customer problem: BQ79731 SPI mode 0 strobes for data on rising edge and changes data on falling edge. But customer was operating SPI master in strobe for data on falling edge and changes data on rising edge. Customer was confused because SPI mode 0 specified in BQ79731 was different from F280039 SPI mode 0. If customer had taken a closer look into timing diagram in both the datasheet, this problem could have been avoided

  • Thank you Manoj,

    My issue is resolved.

  • Closing this thread