Hi,
I am new to the TIVA Series launchpad, any help would be appreciated. I have a question about SPI.
I am trying to send data from SSI2 (configured as master) and receive that data on SSI0 (configured as slave) on a TM4C123GH6PM Micro-controller. I set up the registers of both SSI2 and SSI0 and connected the SSI2 pins to the respective SSI0 pins (clock to clock, FSS to FSS, Rx to Tx and Tx to Rx). The problem I am having is that the SSI2_DR_R and SSI0_DR_R registers stay empty, the data doesn't get transferred into it.
I send 0xFF and when check whether the received data is 0x0:
if (recieved == 0x00) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 2); //Turn on red LED } else { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 4); //Turn on blue LED }
Then the red LED turns on ..... The data I am receiving in SSI0 is 0x00.
Why does the SSI2_DR_R and SSI0_DR_R registers stay empty/0x00000000 ?
My code, using Code Composer Studio 6.1.3:
#include <stdbool.h> #include <stdint.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" int main(void) { uint32_t dataToSend = 0xFF; uint32_t recieved; SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //Enable SSI Peripherals SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); //Enable the ports of SSI0 and SSI2 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Enable PortF (to use the LED) SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); // Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5. GPIOPinConfigure(GPIO_PA2_SSI0CLK); GPIOPinConfigure(GPIO_PA3_SSI0FSS); GPIOPinConfigure(GPIO_PA4_SSI0RX); GPIOPinConfigure(GPIO_PA5_SSI0TX); // Configure the pin muxing for SSI2 functions on port B4, B5, B6, and B7. GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB5_SSI2FSS); GPIOPinConfigure(GPIO_PB6_SSI2RX); GPIOPinConfigure(GPIO_PB7_SSI2TX); //Configure SSI GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2); GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_7 | GPIO_PIN_6 | GPIO_PIN_5 | GPIO_PIN_4); SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_SLAVE, 10000, 8); SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 8); // Enable the SSI modules SSIEnable(SSI0_BASE); SSIEnable(SSI2_BASE); while(1) { SSIDataPut(SSI2_BASE, 0xFF); //Send data through SSI2 while(SSIBusy(SSI2_BASE)) //Wait for transmission to complete { } SSIDataGet(SSI0_BASE, recieved); //recieve if (recieved == 0xFF) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 2); //Turn on red LED } else { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 4); //Turn on blue LED } } return(0); }