This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi TI community,
I am also trying to use Piccolo spi for 8 bit communication. SPIB is acting as master. I have wired issue that MISO line is always high but data is pushed onto MISO line. My slave device is AD1938 (from Analog devices), I am looking into hardware side of it, but want to be sure that my software settings are good.
Can you review below code based on your experience??
================================
GPIO init - for clk, miso and mosi.
GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 3; // Configure GPIO24 as SPISIMOB
GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 3; // Configure GPIO13 as SPISOMIB
GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 3; // Configure GPIO14 as SPICLKB
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0; // Enable pull-up on GPIO24 (SPISIMOB)
GpioCtrlRegs.GPAPUD.bit.GPIO13 = 0; // Enable pull-up on GPIO13 (SPISOMIB)
GpioCtrlRegs.GPAPUD.bit.GPIO14 = 0; // Enable pull-up on GPIO14 (SPICLKB)
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 3; // Asynch input GPIO24 (SPISIMOB)
GpioCtrlRegs.GPAQSEL1.bit.GPIO13 = 3; // Asynch input GPIO13 (SPISOMIB)
GpioCtrlRegs.GPAQSEL1.bit.GPIO14 = 3; // Asynch input GPIO14 (SPICLKB)
===============================
SPI initialization
void SPI_Init(void)
{
EALLOW;
SpibRegs.SPICCR.all =0x000F; // Reset on, rising edge, 16-bit char bits
SpibRegs.SPICTL.all =0x000F; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpibRegs.SPIBRR =0x007F;
SpibRegs.SPICCR.all =0x0007; // Relinquish SPI from Reset
SpibRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
SpibRegs.SPICCR.bit.SPISWRESET = 1;
EDIS;
}
================
SPI read and SPI write API
Uint16 SPI0_Read()
{
SpibRegs.SPITXBUF=(0x00<<8);
while(SpibRegs.SPISTS.bit.INT_FLAG !=1) { }
rdata = (Uint16)(SpibRegs.SPIRXBUF);
rdata = (rdata>>8);
return (rdata);
}
Uint16 SPI0_Write(Uint16 data)
{
Uint16 rdata;
SpibRegs.SPITXBUF=(data<<8);
while(SpibRegs.SPISTS.bit.INT_FLAG !=1) { }
rdata = SpibRegs.SPIRXBUF;
}
Thanks for your help.
Below is pic of output i am getting. (1 is clock, 2. is CS, 3 is MISO, and 4 is MOSI)
full read-write sequence...
write sequence!
read back sequence!!!