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.

Sending data as Slave using SPI

Other Parts Discussed in Thread: EK-TM4C1294XL, TM4C1294NCPDT

Hi,

I really need some help here. 

I'm trying to develop a SPI communication between two peripherals in the same Launchpad (EK-TM4C1294XL). The idea is that both the Master and the Slave can send and receive information. My code until now is quite simple with only Slave sending and Master receiving.

/*
 * main.c
 */

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "inc/hw_memmap.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/ssi.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
#include "inc/hw_ints.h"
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"

#define NUM_SSI_DATA            8

uint32_t ui32SysClkFreq;

//uint32_t pui32DataTx[NUM_SSI_DATA];
//char pui32DataTx[NUM_SSI_DATA];
//char pui32DataRx[NUM_SSI_DATA];
uint8_t pui32DataTx[NUM_SSI_DATA];
uint32_t pui32DataRx[NUM_SSI_DATA];
uint32_t ui32Index = 0;

void SSI1IntHandler(void){

	SSIIntClear(SSI1_BASE, SSI_RXFF);
	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
	UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index]);
	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+1]);
	UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+1]);
	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+2]);
	UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+2]);
	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+3]);
	UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+3]);

}

inline void converteFloatChar(uint32_t numero, uint8_t *vetorEnvio, char codigo) {

	uint8_t aux, dezena, unidade, centena;

	aux = numero*0.01;
	centena = aux;
	aux = numero - aux*100;

	dezena = aux*0.1;
	unidade = aux - dezena*10;

	pui32DataTx[0] = codigo;
	pui32DataTx[1] = centena;
	pui32DataTx[2] = dezena;
	pui32DataTx[3] = unidade;

//	UARTprintf("Centena: %c = %c \nDezena: %u \nUnidade: %u \n", centena, centena+'0', dezena, unidade);
}


int main(void) {
	uint32_t numeroEnviado = 123;
	uint32_t start, delta;

	/****************Time Configuration*****************/
	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC_UP);
	TimerLoadSet(TIMER1_BASE, TIMER_A, UINT32_MAX);
	TimerEnable(TIMER1_BASE, TIMER_A);

	/****************UART Configuration*****************/
	ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1);

	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTStdioConfig(0, 115200, ui32SysClkFreq);

	/**********************SSI**********************/
	// SSI0 -> SLAVE ; SSI1 -> MASTER
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); 
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); 

	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
	GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
	GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);

	GPIOPinConfigure(GPIO_PB5_SSI1CLK);
	GPIOPinConfigure(GPIO_PB4_SSI1FSS);
	GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
	GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);

	GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
			GPIO_PIN_2);

	GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_5 | GPIO_PIN_4);
	GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);

	SSIConfigSetExpClk(SSI1_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
			SSI_MODE_MASTER, 2000000, 8);

	SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
			SSI_MODE_SLAVE, 2000000, 8); 
	SSIEnable(SSI0_BASE);
	SSIEnable(SSI1_BASE);

	UARTprintf("Enviada: a%u\n", numeroEnviado);

	start = TimerValueGet(TIMER1_BASE, TIMER_A);
	converteFloatChar(numeroEnviado, pui32DataTx, 'a');
	delta = TimerValueGet(TIMER1_BASE, TIMER_A) - start;
	UARTprintf("Delta: %u\n" , delta);

	IntMasterEnable();

	SSIIntEnable(SSI1_BASE, SSI_RXFF);

	IntEnable(INT_SSI1);

	while(ui32Index<strlen(pui32DataTx)){
		UARTprintf("Enviando: '%u' \n", pui32DataTx[ui32Index]);
		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
		SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
		SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
		ui32Index++;
	}

	return 0;
}

Inside the while routine to send data as Slave, the slave needs the clock wich is generated by master, so master keep sending some dummy data during it (this isn't ideal for my application but it was a suggestion from a TI employee and now I can finally send using Slave, ty). 

This is what is printed on my serial port:

It seems like it loses the first data and repeat the third one because of that. Also, I tried to comment one line inside the while: 

	while(ui32Index<strlen(pui32DataTx)){
		UARTprintf("Enviando: '%u' \n", pui32DataTx[ui32Index]);
		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
		SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
//		SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
		ui32Index++;
	}

Because I think this line should be only inside the interrupt, but if I do this the interrupt is called 2 times and I didn't understand why this is happening.

So, I didn't have success on my attempts. Does anybody have any suggestion?

Mayli.

  • Hello Mayli

    Whenever you put a data, you must get a data with the SSI controller

    SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
    SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
    SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);


    Regards
    Amit
  • Hi Amit,

    I just changed the while routine as you suggested, but unfortunatelly the interrupt is never called now.

    Mayli.
  • Hello Mayli,

    In the interrupt handler, you must read the data first and then clear the interrupt.

    Regards
    Amit
  • I just did it but the interrupt is still not getting called.

    void SSI1IntHandler(void){

    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
    UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index]);
    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+1]);
    UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+1]);
    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+2]);
    UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+2]);
    SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index+3]);
    UARTprintf("Recebendo: '%u' \n", pui32DataRx[ui32Index+3]);
    SSIIntClear(SSI1_BASE, SSI_RXFF);
    }
  • Hello Mayli

    The SSI FIFO is 8 locations deep. So the RXFF interrupt requires that 4 data bytes be available on the slave side and not to be read out in the main loop or the debugger register window. If you have a debugger register window open, then please close it.

    Regards
    Amit
  • Hi Amit,

    I've realized this on my attempts so I keep closing the debug window to see what is in my serial port. Even so, this is what I got with the debug window closed:

    As I told before, without that second SSIDataGet in the while routine, the interruption is called but the receiveing FIFO get wrong data:

    Please, I need that this communication works. 

    Thank you very much,

    Mayli.

  • Hello Mayli

    Can you send your CCS project (zipped and attached) to the post along with the connections that you have made on the board, so that I can reproduce the setup and the issue.

    Regards
    Amit
  • Hello Amit, here is my CCS project file:

    Comunicacao_SSI_Interrupt.rar

    My connections:

    PE5 <-> PA4

    PE4 <-> PA5

    PA2 <-> PB5

    PA3 <-> PB4

    Thank you very much !!!!!!

    Mayli.

  • Hello Mayli,

    Give me a day or 2...

    Regards
    Amit
  • Ok Amit,

    Thank you ! 

    Mayli.

  • Hello Mayli

    I ran the code on the EK-TM4C1294XL and I see a fundamental problem

    1. The master and slave are both running on the same micro and hence there is a program interference due to use of shared variables

    2. The master send a byte and receives a byte from the slave. Then the slave writes a byte to the buffer. It is the next byte write from master that will cause it to be shifted on the bus. Thus at the end of the code execution a dummy write from master is required.

    3. Instead of using the RXFF interrupt bit, use the RXTO interrupt bit.

    I have made the modification to the project source code and attached the same

    /*
     * main.c
     */
    
    #include <stdio.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/ssi.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    #include "inc/hw_ints.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/timer.h"
    
    #define NUM_SSI_DATA            4
    
    uint32_t ui32SysClkFreq;
    
    //uint32_t pui32DataTx[NUM_SSI_DATA];
    //char pui32DataTx[NUM_SSI_DATA];
    //char pui32DataRx[NUM_SSI_DATA];
    uint8_t pui32DataTx[NUM_SSI_DATA];
    uint32_t pui32DataRx[NUM_SSI_DATA];
    uint32_t ui32Index = 0;
    
    void SSI1IntHandler(void)
    {
    	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index]);
    	SSIIntClear(SSI1_BASE, SSI_RXTO);
    	UARTprintf("Receiving: '%u' \n", pui32DataRx[ui32Index]);
    }
    
    inline void converteFloatChar(uint32_t numero, uint8_t *vetorEnvio, char codigo) {
    
    	uint8_t aux, dezena, unidade, centena;
    
    	aux = numero*0.01;
    	centena = aux;
    	aux = numero - aux*100;
    
    	dezena = aux*0.1;
    	unidade = aux - dezena*10;
    
    	pui32DataTx[0] = codigo;
    	pui32DataTx[1] = centena;
    	pui32DataTx[2] = dezena;
    	pui32DataTx[3] = unidade;
    
    //	UARTprintf("Centena: %c = %c \nDezena: %u \nUnidade: %u \n", centena, centena+'0', dezena, unidade);
    }
    
    
    int main(void) {
    	uint32_t numeroEnviado = 123;
    	uint32_t start, delta;
    
    	/****************Time Configuration*****************/
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC_UP);
    	TimerLoadSet(TIMER1_BASE, TIMER_A, UINT32_MAX);
    	TimerEnable(TIMER1_BASE, TIMER_A);
    
    	/****************UART Configuration*****************/
    	ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
    	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1);
    
    	GPIOPinConfigure(GPIO_PA0_U0RX);
    	GPIOPinConfigure(GPIO_PA1_U0TX);
    	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    	UARTStdioConfig(0, 115200, ui32SysClkFreq);
    
    	/**********************SSI**********************/
    	// SSI0 -> SLAVE ; SSI1 -> MASTER
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //verificar se nao tem nenhum pino no PB5 e PB4
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //verificar se nao tem nenhum pino no PE5 e PE4
    
    	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    	GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
    	GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
    
    	GPIOPinConfigure(GPIO_PB5_SSI1CLK);
    	GPIOPinConfigure(GPIO_PB4_SSI1FSS);
    	GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
    	GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);
    
    	GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
    			GPIO_PIN_2);
    
    	GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_5 | GPIO_PIN_4);
    	GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
    	SSIConfigSetExpClk(SSI1_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
    			SSI_MODE_MASTER, 2000000, 8); //verificar parametros
    
    	SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
    			SSI_MODE_SLAVE, 2000000, 8); //verificar parametros
    
    	SSIEnable(SSI0_BASE);
    	SSIEnable(SSI1_BASE);
    
    	UARTprintf("Send: a%u\n", numeroEnviado);
    
    	start = TimerValueGet(TIMER1_BASE, TIMER_A);
    	converteFloatChar(numeroEnviado, pui32DataTx, 'a');
    	delta = TimerValueGet(TIMER1_BASE, TIMER_A) - start;
    	UARTprintf("Delta: %u\n" , delta);
    
    	IntMasterEnable();
    
    	SSIIntEnable(SSI1_BASE, SSI_RXTO);
    
    	IntEnable(INT_SSI1);
    
    	while(ui32Index<strlen(pui32DataTx)){
    		UARTprintf("Sending: '%u' \n", pui32DataTx[ui32Index]);
    		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    		SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
    		ui32Index++;
    	}
    
    	SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    	while(1);;
    }
    

    Regards

    Amit

  • Hello Amit,

    Thank you very much for your help.
    About your comments,
    1 - I'm using the launchpad as a initial test but actually i will use two TM4C1294NCPDT as Master and Slave (thanks for the note).

    2 - Ok, it makes sense.

    3 - Here is the problem. I was using RXFF to avoid trying to write in a full FIFO. With your solution (using RXTO) the algorithm works only when the UARTprintf is present. When it's not, the time out happens only after it's full because another byte is sent before 32 SSI clock periods. The UARTprintf is only for debugging purposes so it will not be in the final code.

    My data will be always multiple of 4 bytes that's why RXFF sounds more suitable to me. With your changes is there some way to also work with RXFF interrupt ??

    Just one more thing, even in your code, the first byte received is always '0', followed by the actual first byte sent by Slave. How do I not get this "trash byte"?


    Thanks a lot !
    Mayli.

  • Hello Mayli

    Concerning point 3, the master controls the clock to the slave. So after sending 4 bytes, if it decides not to send any more byte, then the 32 SSI clock period on the master side shall elapse allowing the master to read the data.

    Regards
    Amit
  • Hi Amit, thanks for your patience,

    I'm afraid of losing bytes when the FIFO is full. I also noticed that the first data received is always a 0 while the actual first data is the second data received.  

    I changed the following things:

    1- Now i'm sending 12 bytes :

         #define NUM_SSI_DATA            12

    2 - I commented the UARTprintfs inside the interrupt and inside the while routine.

    3 - I  used different index's for each module (master and slave)

    4 - I added some UARTprintf's at the end of the code to see what is in pui32DataTx and pui32DataRx.

          for (ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++){

    UARTprintf("Sent: '%u' in position '%u' \n", pui32DataTx[ui32Index], ui32Index);

    UARTprintf("Received: '%u' in position '%u' \n", pui32DataRx[ui32Index], ui32Index);

    }

    UARTprintf("Received: '%u' in position '%u' \n", pui32DataRx[ui32Index], ui32Index);

    Here is  the output:

    As shown in the previous picture, the last datas were lost.

    The full code is attached:

    /*
     * main.c
     */
    
    #include <stdio.h>
    #include <stdbool.h>
    #include <stdint.h>
    #include <string.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/ssi.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    #include "inc/hw_ints.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/timer.h"
    
    #define NUM_SSI_DATA            12
    
    uint32_t ui32SysClkFreq;
    
    //uint32_t pui32DataTx[NUM_SSI_DATA];
    //char pui32DataTx[NUM_SSI_DATA];
    //char pui32DataRx[NUM_SSI_DATA];
    uint8_t pui32DataTx[NUM_SSI_DATA];
    uint32_t pui32DataRx[NUM_SSI_DATA+1];
    uint32_t ui32Index = 0, ui32Index2 = 0;
    
    void SSI1IntHandler(void)
    {
    	SSIDataGet(SSI1_BASE, &pui32DataRx[ui32Index2]);
    	ui32Index2++;
    	SSIIntClear(SSI1_BASE, SSI_RXTO);
    //	UARTprintf("Receiving: '%u' \n", pui32DataRx[ui32Index]);
    }
    
    inline void converteFloatChar(uint32_t numero, uint8_t *vetorEnvio, char codigo) {
    
    	uint8_t aux, dezena, unidade, centena;
    
    	aux = numero*0.01;
    	centena = aux;
    	aux = numero - aux*100;
    
    	dezena = aux*0.1;
    	unidade = aux - dezena*10;
    
    	pui32DataTx[0] = codigo;
    	pui32DataTx[1] = centena;
    	pui32DataTx[2] = dezena;
    	pui32DataTx[3] = unidade;
    
    //	UARTprintf("Centena: %c = %c \nDezena: %u \nUnidade: %u \n", centena, centena+'0', dezena, unidade);
    }
    
    
    int main(void) {
    	uint32_t numeroEnviado = 123;
    	uint32_t start, delta;
    
    	/****************Time Configuration*****************/
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    	TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC_UP);
    	TimerLoadSet(TIMER1_BASE, TIMER_A, UINT32_MAX);
    	TimerEnable(TIMER1_BASE, TIMER_A);
    
    	/****************UART Configuration*****************/
    	ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
    	GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1);
    
    	GPIOPinConfigure(GPIO_PA0_U0RX);
    	GPIOPinConfigure(GPIO_PA1_U0TX);
    	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    	UARTStdioConfig(0, 115200, ui32SysClkFreq);
    
    	/**********************SSI**********************/
    	// SSI0 -> SLAVE ; SSI1 -> MASTER
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //verificar se nao tem nenhum pino no PB5 e PB4
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //verificar se nao tem nenhum pino no PE5 e PE4
    
    	GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    	GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    	GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
    	GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
    
    	GPIOPinConfigure(GPIO_PB5_SSI1CLK);
    	GPIOPinConfigure(GPIO_PB4_SSI1FSS);
    	GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
    	GPIOPinConfigure(GPIO_PE5_SSI1XDAT1);
    
    	GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
    			GPIO_PIN_2);
    
    	GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_5 | GPIO_PIN_4);
    	GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
    	SSIConfigSetExpClk(SSI1_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
    			SSI_MODE_MASTER, 2000000, 8); //verificar parametros
    
    	SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,
    			SSI_MODE_SLAVE, 2000000, 8); //verificar parametros
    
    	SSIEnable(SSI0_BASE);
    	SSIEnable(SSI1_BASE);
    
    	UARTprintf("Send: a%u\n", numeroEnviado);
    
    	start = TimerValueGet(TIMER1_BASE, TIMER_A);
    	converteFloatChar(numeroEnviado, pui32DataTx, 'a');
    	delta = TimerValueGet(TIMER1_BASE, TIMER_A) - start;
    	UARTprintf("Delta: %u\n" , delta);
    
    	IntMasterEnable();
    
    	SSIIntEnable(SSI1_BASE, SSI_RXTO);
    
    	IntEnable(INT_SSI1);
    
    	for (ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++){
    		pui32DataTx[ui32Index] = ui32Index+1;
    	}
    	ui32Index = 0;
    
    	while(ui32Index<NUM_SSI_DATA){
    		//UARTprintf("Sending: '%u' \n", pui32DataTx[ui32Index]);
    		SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    		SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
    		ui32Index++;
    	}
    	SSIDataPut(SSI1_BASE, pui32DataTx[ui32Index]);
    
    	for (ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++){
    		UARTprintf("Sent: '%u' in position '%u' \n", pui32DataTx[ui32Index], ui32Index);
    		UARTprintf("Received: '%u' in position '%u' \n", pui32DataRx[ui32Index], ui32Index);
    	}
    	UARTprintf("Received: '%u' in position '%u' \n", pui32DataRx[ui32Index], ui32Index);
    
    	while(1);;
    }
    

  • Hello Mayli,

    I think you are still missing the point here. Since the Master controls the rate of traffic, it can throttle the clock and still use RXTO to read the data

    Regards
    Amit
  • In the code that you sent, the master controls the start of the transmission. But as you said Master can also throttle the clock, so what do I have to do to throttle the clock when the FIFO is full to prevent data loss ?

  • Stop transmitting.

    Robert