Other Parts Discussed in Thread: AMC7820
Tool/software: Code Composer Studio
Hi,
In my design I have to configure 2 slave modules in SPI2.
The slave module i used is TI- AMC7820.
First i tried to configure single SPI module.
The Pins I used was PD0,PD1 and PD3. The chip select was PK3 for slave 1.
I have modified the code for write 0x2345 to a register and read back it. But what I read back is NULL
The init,read and write functions are as below.
void SSI2Init(void) //SPI 2 initialization { // // The SSI2 peripheral must be enabled for use. // SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);// CS1 K3 // // Configure the pin muxing for SSI0 functions on port D0, D1, and D3. // GPIOPinConfigure(GPIO_PD0_SSI2XDAT1); GPIOPinConfigure(GPIO_PD1_SSI2XDAT0); GPIOPinConfigure(GPIO_PD3_SSI2CLK); // GPIOPinConfigure(GPIO_PA3_SSI0FSS);// This is not done as CS is a GPIO pin GPIOPinTypeGPIOOutput(GPIO_PORTK_BASE, GPIO_PIN_3);// CS1 for slave 1 as GPIO output pin GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3,GPIO_PIN_3);//make it high, as it is active low // // Configure the GPIO settings for the SSI pins. // GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_1 | GPIO_PIN_0); // // Configure and enable the SSI port for SPI master mode. Use SSI2, // SSIConfigSetExpClk(SSI2_BASE, g_ui32SysClock, SSI_FRF_TI, SSI_MODE_MASTER, 1000000, 8); // // Enable the SSI2 module. // SSIEnable(SSI2_BASE); // // Read any residual data from the SSI port. // while(SSIDataGetNonBlocking(SSI2_BASE, &pui32DataRx[0])) { } } void SPI2Read(void) { pui32DataTx[0]=0x82;// for reading from register pui32DataTx[1]=0x40; GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3 ,0);// CS LOw; AMC expects Active low control signal for(ui32Index = 0; ui32Index < 2; ui32Index++) { // // Send the data using the "blocking" put function. This function // will wait until there is room in the send FIFO before returning. // This allows you to assure that all the data you send makes it into // the send FIFO. // SSIDataPut(SSI2_BASE, pui32DataTx[ui32Index]); } // // Wait until SSI0 is done transferring all the data in the transmit FIFO. // while(SSIBusy(SSI2_BASE)) { } // Receive 2 bytes of data. // for(ui32Index = 0; ui32Index < 2; ui32Index++) { // // Receive the data using the "blocking" Get function. This function // will wait until there is data in the receive FIFO before returning. // SSIDataGet(SPIBase, &pui32DataRx[ui32Index]); // Since we are using 8-bit data, mask off the MSB. // pui32DataRx[ui32Index] &= 0x00FF; } GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3 ,GPIO_PIN_3 );// Reset CS to High } void SPIwrite(void) { pui32DataTx[0]=0x02; pui32DataTx[1]=0x40; pui32DataTx[2]=0x23; pui32DataTx[3]=0x45; GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3 ,0)// CS LOw; AMC expects Active low control signal for(ui32Index = 0; ui32Index < 4; ui32Index++) { // // Send the data using the "blocking" put function. This function // will wait until there is room in the send FIFO before returning. // This allows you to assure that all the data you send makes it into // the send FIFO. // SSIDataPut(SSI2_BASE, pui32DataTx[ui32Index]); } // // Wait until SSI0 is done transferring all the data in the transmit FIFO. // while(SSIBusy(SSI2_BASE)) { } GPIOPinWrite(GPIO_PORTK_BASE, GPIO_PIN_3 ,GPIO_PIN_3 );// Reset CS to High }
Please Help me.
Thanks in advance.