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: Cannot read the correct data from SPI

Part Number: TMS320F280039C
Other Parts Discussed in Thread: SYSCONFIG,

I am currently learning to use TI microcontrollers. I am using sysconfig to generate the driver code for SPI. I am using TMS320F280039C launchpad as a slave device and an arduino as a master. I am sending the data 0x2 from arduino but TMS320F280039C is getting some data but its not 0x2. The data received by TMS320F280039C always varies and its not consistent.

I have connected the SPI pins as follows
POCI - MISO (Arduino UNO) 
PICO - MOSI (Arduino UNO) 

CLK - CLK (Arduino UNO) 

PTE - CS (Arduino UNO) 

#include "driverlib.h"
#include "device.h"
#include "board.h"
#include <stdio.h>
//
// Main
//
#define CPU_RATE 8.33L
#define CPU_FRQ_120MHZ 1

uint16_t test =0;

#define DELAY_US(A) F28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)

static void UART_TX(char a[]) {
while ((*a) != '\0') {
SCI_writeCharBlockingNonFIFO(mySCI0_BASE,*a);
a = a + 1;
}
char test = '\n';
SCI_writeCharBlockingNonFIFO(mySCI0_BASE, test);
}

void main(void)
{
// Device Initialization
Device_init();
//
// Initializes Peripheral Interrupt Expansion module (PIE) and clears PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();
//
// Initializes the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();
Board_init();
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;
char data[100] = "Hello world";
while(1)
{

test = SPI_readDataBlockingNonFIFO(mySPI0_BASE);

sprintf( data,"Data Received %u",test);
UART_TX(data);
}
}

 

  • Hi Abhijith,

    Since you have the SPI configured for 8-bit data width, only the lower 8 bits of the receive buffer will contain valid data.

    The SPI_readDataBlockingNonFIFO() function returns the entire 16-bit receive buffer, from which you can mask out the relevant bits (in this case, with 0x00FF) to get the actual received data.

    Thanks,

    Arnav