Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
I have a TIVA TM4c1294NCPT launchpad and have SSI2 setup as a master SPI communicating to SSI3 slave SPI on the same development board with jumper wires. This has worked well for me. Now I need to change the slave SPI from SSI3 to SS1 but I can't seem to get this to work. My jumper wire setup is as follows:
Generic setup: SSI2Clk -> SSIxCLK, SSI2Fss -> SSIxFss, SSI2Data1->SSIxData0, SSI2Data0->SSIxData1,
SSI2->SSI3: PD3->PQ0, PD2->PQ1, PD0->PQ2, PD1->PQ3
SSI2->SSI1: PD3->PB5, PD2->PB4, PD0->PE4, PD1->PE5
The program compiles and the master seems to issue messages OK. When the SPI slave is SSI3, the messages are received. My SPI slave task is as follows:
void SPIserver(UArg arg0, UArg arg1) { SPI_Handle serverSpi; SPI_Params serverSpiParams; SPI_Transaction serverTransaction; bool ServertransferOK; /* Initialize SPI handle with slave mode */ SPI_Params_init(&serverSpiParams); serverSpiParams.mode = SPI_SLAVE; serverSpiParams.bitRate = 12500000; serverSpiParams.transferMode = SPI_MODE_BLOCKING; serverSpiParams.frameFormat = SPI_POL0_PHA1; // polarity and phase == SPI_POL0_PHA0, SPI_POL0_PHA1, SPI_POL1_PHA0, SPI_POL1_PHA1 //serverSpiParams.transferTimeout = SPI_WAIT_FOREVER; serverSpiParams.dataSize = 10; serverSpi = SPI_open(Board_SPI3, &serverSpiParams); if (serverSpi == NULL) { System_abort("Error initializing SPI\n"); } else { System_printf("Server SPI initialized\n"); } while(1) { //Step 1: receive new SPI data serverTransaction.count = SPI_MSG_LENGTH; serverTransaction.txBuf = NULL; serverTransaction.rxBuf = (Ptr)serverRxBuffer; ServertransferOK = SPI_transfer(serverSpi, &serverTransaction); } }
This checks out OK. Now when I change my hook-up wires from SSI3 to SSI1 as noted earlier and change "Board_SPI3" to ""Board_SPI1" in SPI_open() in the above program, my slave SPI stays in a blocking mode. The constant definitions are as follows:
#define Board_SPI1 EK_TM4C1294XL_SPI1
#define Board_SPI2 EK_TM4C1294XL_SPI2
#define Board_SPI3 EK_TM4C1294XL_SPI3
What am I missing. Is there some other configuration that I need to configure for SSI1 that I didn't for SSI3? This is similar to a post about a SPI_transfer crash reported a few days ago by digvijay khambe. Any help would be great appreciated. Please find the relavent code posted below. Thank you!
/*! * @def EK_TM4C1294XL_SPIName * @brief Enum of SPI names on the EK_TM4C1294XL dev board */ typedef enum EK_TM4C1294XL_SPIName { EK_TM4C1294XL_SPI1 = 0, EK_TM4C1294XL_SPI2, EK_TM4C1294XL_SPI3, EK_TM4C1294XL_SPICOUNT } EK_TM4C1294XL_SPIName; /* * =============================== SPI =============================== */ /* Place into subsections to allow the TI linker to remove items properly */ #if defined(__TI_COMPILER_VERSION__) #pragma DATA_SECTION(SPI_config, ".const:SPI_config") #pragma DATA_SECTION(spiTivaDMAHWAttrs, ".const:spiTivaDMAHWAttrs") #endif #include <ti/drivers/SPI.h> #include <ti/drivers/spi/SPITivaDMA.h> SPITivaDMA_Object spiTivaDMAObjects[EK_TM4C1294XL_SPICOUNT]; #if defined(__TI_COMPILER_VERSION__) #pragma DATA_ALIGN(spiTivaDMAscratchBuf, 32) #elif defined(__IAR_SYSTEMS_ICC__) #pragma data_alignment=32 #elif defined(__GNUC__) __attribute__ ((aligned (32))) #endif uint32_t spiTivaDMAscratchBuf[EK_TM4C1294XL_SPICOUNT]; const SPITivaDMA_HWAttrs spiTivaDMAHWAttrs[EK_TM4C1294XL_SPICOUNT] = { { .baseAddr = SSI1_BASE, .intNum = INT_SSI1, .intPriority = (~0), .scratchBufPtr = &spiTivaDMAscratchBuf[0], .defaultTxBufValue = 0, .rxChannelIndex = UDMA_SEC_CHANNEL_SSI1RX, .txChannelIndex = UDMA_SEC_CHANNEL_SSI1TX, .channelMappingFxn = uDMAChannelAssign, .rxChannelMappingFxnArg = UDMA_CH10_SSI1RX, .txChannelMappingFxnArg = UDMA_CH11_SSI1TX }, { .baseAddr = SSI2_BASE, .intNum = INT_SSI2, .intPriority = (~0), .scratchBufPtr = &spiTivaDMAscratchBuf[1], .defaultTxBufValue = 0, .rxChannelIndex = UDMA_SEC_CHANNEL_UART2RX_12, .txChannelIndex = UDMA_SEC_CHANNEL_UART2TX_13, .channelMappingFxn = uDMAChannelAssign, .rxChannelMappingFxnArg = UDMA_CH12_SSI2RX, .txChannelMappingFxnArg = UDMA_CH13_SSI2TX }, { .baseAddr = SSI3_BASE, .intNum = INT_SSI3, .intPriority = (~0), .scratchBufPtr = &spiTivaDMAscratchBuf[2], .defaultTxBufValue = 0, .rxChannelIndex = UDMA_SEC_CHANNEL_TMR2A_14, .txChannelIndex = UDMA_SEC_CHANNEL_TMR2B_15, .channelMappingFxn = uDMAChannelAssign, .rxChannelMappingFxnArg = UDMA_CH14_SSI3RX, .txChannelMappingFxnArg = UDMA_CH15_SSI3TX } }; const SPI_Config SPI_config[] = { { .fxnTablePtr = &SPITivaDMA_fxnTable, .object = &spiTivaDMAObjects[0], .hwAttrs = &spiTivaDMAHWAttrs[0] }, { .fxnTablePtr = &SPITivaDMA_fxnTable, .object = &spiTivaDMAObjects[1], .hwAttrs = &spiTivaDMAHWAttrs[1] }, { .fxnTablePtr = &SPITivaDMA_fxnTable, .object = &spiTivaDMAObjects[2], .hwAttrs = &spiTivaDMAHWAttrs[2] }, {NULL, NULL, NULL} }; /* * ======== EK_TM4C1294XL_initSPI ======== */ void EK_TM4C1294XL_initSPI(void) { /* SSI1 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); GPIOPinConfigure(GPIO_PB5_SSI1CLK); GPIOPinConfigure(GPIO_PB4_SSI1FSS); GPIOPinConfigure(GPIO_PE4_SSI1XDAT0); GPIOPinConfigure(GPIO_PE5_SSI1XDAT1); GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5); GPIOPinTypeSSI(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5); /* SSI2 */ /* * NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI2 or I2C7. Thus, * a conflict occurs when the I2C & SPI drivers are used simultaneously in * an application. Modify the pin mux settings in this file and resolve the * conflict before running your the application. */ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); 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); // /* SSI3 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3); GPIOPinConfigure(GPIO_PQ0_SSI3CLK); GPIOPinConfigure(GPIO_PQ1_SSI3FSS); GPIOPinConfigure(GPIO_PQ2_SSI3XDAT0); GPIOPinConfigure(GPIO_PQ3_SSI3XDAT1); GPIOPinTypeSSI(GPIO_PORTQ_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); EK_TM4C1294XL_initDMA(); SPI_init(); }