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 slave mode not working when clock mode is selected as rising edge-half cycle delay and falling edge-no delay

Part Number: TMS320F28379D
Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I am trying to perform SPI communication between F28379D launchpad (Master) and F28379D ControlCard (Slave). I have written the code following the SPI loopback example shipped in ControlSuite. I configure the master to send a counter data continuously over SPI and slave is configured to read the received data continuously. During transmit I ensure TXFFST is empty before placing the new data on SPITXBUF and while receiving I will check RXFFST if new data is available before reading the data from SPIRXBUF.

When I configure both master and slave either as rising edge-no delay or as falling edge-delay half cycle clock modes, I can see the data is received properly in slave. But if I configure both master and slave either as rising edge-half cycle delay or as falling edge-no delay, I am not able to read properly from SPIRXBUF. In these cases, SPIDAT is updated by the received data regularly but the data from SPIDAT is not loaded properly into SPIRXBUF and RXFFST is zero (attached snapshot). Also the SIMO data along with clock and CS is present and can be confirmed using CRO (attached screenshot) and the SIMO data observed in CRO matches with the data observed in SPIDAT. 

If I replace the slave with other board like F28075 i can see the data being received properly in SPIRXBUF. Can you check once and let me know the reason for this issue? I have attached the code used for both master and slave for the reference.

Thanks,

Aditya

SPI Master

Example_2837xDSpi_MasterTransmit.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//###########################################################################
// FILE: Example_2837xDSpi_MasterTransmit.c
// TITLE: Transmit Tx data from SPI master
//
//! This program transmits data from SPI master continuously. This program is configured to use on
//! F28379D Launchpad with modification for system clock and SPi pins.
//!
//! A stream of data is sent.
//! The sent data looks like this: \n
//! 0000 0001 0002 0003 0004 0005 0006 0007 .... FFFE FFFF \n
//! This pattern is repeated forever.
//!
//! \b Watch \b Variables \n
//! - \b sdata - sent data
#include "F28x_Project.h" // Device Headerfile and Examples Include File
// Function prototype
void delay_loop(void);
void spi_xmit(Uint16 a);
void spi_fifo_init(void);
void spi_init(void);
void InitSpiaGpio(void);
void InitSysCtrl1(void);
Uint16 sdata = 0; // send data
void main(void)
{
// Initialize System Control
// PLL, WatchDog, enable Peripheral Clocks
InitSysCtrl1();
// Initialize GPIO
InitSpiaGpio();
// Clear all __interrupts and initialize PIE vector table
// Disable CPU __interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE __interrupts disabled and flags
// are cleared.
InitPieCtrl();
// Disable CPU __interrupts and clear all CPU __interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the __interrupt
// is not used in this example.
InitPieVectTable();
// Initialize the Device Peripherals
spi_fifo_init(); // Initialize the Spi FIFO
spi_init(); // init SPI
// Transmit the data continuously
// Interrupts are not used in this example.
sdata = 0x0000;
for(;;)
{
// Transmit data
spi_xmit(sdata);
delay_loop();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

SPI Slave

Example_2837xDSpi_SlaveReceive.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//###########################################################################
// FILE: Example_2837xDSpi_Slavereceive.c
// TITLE: Receive data from SPI master as slave
//
//! This program receive data from SPI master continuously. This program is configured to use on
//! F28379D ControlCard.
//!
//! A stream of data is received.
//! The received data looks like this: \n
//! 0000 0001 0002 0003 0004 0005 0006 0007 .... FFFE FFFF \n
//! This pattern is repeated forever.
//!
//! \b Watch \b Variables \n
//! - \b rdata - received data
#include "F28x_Project.h" // Device Headerfile and Examples Include File
// Function prototypes
void delay_loop(void);
void spi_fifo_init(void);
void spi_init(void);
void error(void);
void InitSysCtrl1(void);
void InitSpiaGpio(void);
Uint16 rdata = 0; // received data
void main(void)
{
// Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
InitSysCtrl1();
// Initialize GPIO
// Setup only the GP I/O only for SPI-A functionality
InitSpiaGpio();
// Clear all __interrupts and initialize PIE vector table
// Disable CPU __interrupts
DINT;
// Initialize PIE control registers to their default state.
// The default state is all PIE __interrupts disabled and flags
// are cleared.
InitPieCtrl();
// Disable CPU __interrupts and clear all CPU __interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the __interrupt
// is not used in this example.
InitPieVectTable();
// Initialize the Device Peripherals
spi_fifo_init(); // Initialize the Spi FIFO
spi_init(); // init SPI
// Receive data from master continuously
for(;;)
{
if(SpiaRegs.SPIFFRX.bit.RXFFST >= 1){
//if(SpiaRegs.SPISTS.bit.INT_FLAG == 1){
rdata = SpiaRegs.SPIRXBUF;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Aditya,

    If you are able to swap in another device with the same code and it works, I'm leaning towards this being a hardware setup issue.  However, since it works in some modes that is not a certainty.

    Can you describe your hardware connections between the launchpad and controlcard? Are you using jumper wires? Which GPIOs on each device are you using?

    Regards,

    Kris

  • Hi Kris,

    I am using jumper wires for connection between Master and Slave. I am using GPIO58-SIMO(pin15-J2), GPIO59-SOMI(pin14-J2), GPIO60-CLK(pin7-J1) and GPIO61-STE(pin19-J2) in Launchpad for master and GPIO16-SIMO(pin67), GPIO17-SOMI(pin69), GPIO18-CLK(pin71) and GPIO19-STE(pin73) in Controlcard with docking station for slave. You can take a look at the .c files I have attached in my first post for the GPIO configuration I am doing along with the SPI initialization.

    Thanks,
    Aditya