Part Number: TM4C1294NCPDT
Tool/software: Code Composer Studio
Hii,
I am using TM4C1294NCPDT part number and Code Composer Studio.. My Launchpad is acting as Master and as well as Slave also..
Master pin configuration is:
PA2 -------------- SSI0CLK
PA3 ----------- SSI0FSS
PA4 ------------ SSI0XDAT0 // MOSI
PA5 ------------- SSI0XDAT1 // MISO
Slave pin configuration is:
PD3 -------------- SSI0CLK
PD2 ----------- SSI0FSS
PD1 ------------ SSI0XDAT0 // MOSI
PD0 ------------- SSI0XDAT1 // MISO
I am not able to observe the data in UART console but in console it is showing "FAILED"....
Kindly go through the below code.. Is there any new things to add..
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.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 "utils/uartstdio.c"
#define NUM_SSI_DATA 15
void InitConsole(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTStdioConfig(0, 115200, 16000000);
}
void ssi_init(void)
{
uint32_t ui32SysClkFreq;
uint32_t temp;
ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
///////////// Master ///////////////////////////////////
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 8);
SSIEnable(SSI0_BASE);
/////////// Slave /////////////////////////////////////
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinConfigure(GPIO_PD3_SSI2CLK);
GPIOPinConfigure(GPIO_PD2_SSI2FSS);
GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_SLAVE, 10000, 8);
SSIEnable(SSI2_BASE);
}
void main(void)
{
uint32_t ui32Index;
uint32_t ui32Data;
char spi_data_received_back[NUM_SSI_DATA];
uint32_t spi_received_char;
const char spi_test_command[NUM_SSI_DATA] = {"This is a test\0"};
bool pass_or_fail;
InitConsole();
ssi_init();
memset(spi_data_received_back, '\0', NUM_SSI_DATA);
for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
{
ui32Data = spi_test_command[ui32Index];
SSIDataPut(SSI0_BASE, ui32Data);
// SSIDataGet waits until a character is received
SSIDataGet(SSI0_BASE, &spi_received_char); // Dummy read to empty master rx buffer
SSIDataGet(SSI2_BASE, &spi_received_char); // Get data from slave rx buffer
UARTprintf("Data = %c\n",spi_received_char);
SSIDataPut(SSI2_BASE, spi_received_char); // send back to master
spi_data_received_back[ui32Index] = (char)spi_received_char;
}
if(strcmp(spi_test_command, spi_data_received_back) == 0)
{
pass_or_fail = 1;
UARTprintf("\n\rPASSED\n\r");
}
else
{
pass_or_fail = 0;
UARTprintf("\n\rFAILED\n\r");
}
}
Thanks & Regards,
Venkatadri