Hi,
I need some advice on connecting the TIVA C Launchpad(Master) with 16 bit MCU(MSP430) through SPI.
The SSI is set for 1MHz frequency and 8-bit mode.The slave MSP430G2533 is running at 16mhz.
The slave reset(CS) is done through a GPIO.
The communications seems to be proper but I always receive garabge data on both the
Master and Slave buffers. Below is the code used from the StellarisWare.
I have been trying this for a while without success, please let me know if there is anything
else to be considered when using TIVA C's SSI module.
int main()
{
// Number of bytes to send and receive.
//
#define NUM_SSI_DATA 7
unsigned long ulDataTx;
unsigned long ulDataRx;
unsigned long ulindex;
// Set the clocking to run directly from the crystal.
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
// The SSI0 peripheral must be enabled for use.
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
// The SSI0 peripheral must be enabled for use.
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
// TODO: change this to whichever GPIO port you are using.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
// TODO: change this to select the port/pin you are using.
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
// Configure the GPIO settings for the SSI pins.
// SSI0CLK - PF2 (was PA2)
// SSI0Fss - PF3 (was PA3)
// SSI0Rx - PF0 (was PA4)
// SSI0Tx - PF1 (was PA5)
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5| GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2);
// Configure and enable the SSI port for SPI master mode. Use SSI0,
// system clock supply, idle clock level low and active low clock in
// freescale SPI mode, master mode, 1MHz SSI frequency, and 8-bit data.
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8);
// Enable the SSI0 module.
SSIEnable(SSI0_BASE);
// Read any residual data from the SSI port.
while(SSIDataGetNonBlocking(SSI0_BASE, &ulDataRx))
{
}
// Send N bytes of data.
for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
{
ulDataTx = ulindex;
// Send the data using the "blocking" put function. This function
// will wait until there is room in the send FIFO before returning.
SSIDataPut(SSI0_BASE,ulDataTx);
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
while(SSIBusy(SSI0_BASE))
{
}
//Receive Data
SSIDataGet(SSI0_BASE,&ulDataRx);
//Mask off the 8 bit data
ulDataRx &= 0x00FF;
}
}