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 all,
I am using tm4c129encpdt controller interfaced with ads1271 ADC ic (single IC). I configured microcontroller with 120MHZ clock speed.
ADS1271 setting -> MODE: high resolution
FORMATE: SPI
First i tried to read ads1271 with gpio pin configuration and sucessfuly i read ads1271 with gpio pins.My code is as bellow
while(1)
{
if(GPIOPinREAD(GPIO_PORTD_BASE,GPIO_PIN_4)==0) // DRDY pin
{
for(i=23;i>=0;i--)
{
dt=GPIOPinRead(GPIO_PORTD_BASE,GPIO_PIN_0)==0) // DOUT pin
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_3,0); // Clock low
GPIOPinWrite(GPIO_PORTD_BASE,GPIO_PIN_3,GPIO_PIN_3); // clock high
data1 = (data1 | (dt<<i) ); // collect data in data1
Delay(5); // 5microsec delay
}
}
}
Now i want to read this ADS1271 ic with SPI configuration. My code is as bellow,
***************************************************************************************************************
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
GPIOPinConfigure(GPIO_PD0_SSI2XDATA1); // MISO
GPIOPinConfigure(GPIO_PD3_SSI2CLK); // clock
SSIConfigSetExpClk(SSI2_BASE, 120000000,SSI_FRF_MODE_3,SSI_MODE_MASTER,2000000,8,);
while(1)
{
if(GPIOPinREAD(GPIO_PORTD_BASE,GPIO_PIN_4)==0) // DRDY pin
{
for(i=2;i>=0;i--)
{
SSIDataPut1(SSI2_BASE,DUMMY); // put dummy byte before reading data
while(SSIBusy(SSI2_BASE));
SSIDataGet1(SSI2_BASE,&dt); // read 8 bit data
data1 = (data1 | (dt<<i) );
Delay(5); // 5microsec delay
}
}
}
This code is not working please suggest me any solution.
******************************************************************************************************************
Put and get function is as bellow
void SSIDataPut1(uint32_t ui32Base, uint8_t ui32Data)
{
while(!(HWREG(ulBase + SSI_O_SR) & SSI_SR_TNF))
{
}
// Write the data to the SSI.
HWREG(ulBase + SSI_O_DR) = ui32Data;
}
void SSIDataGet1(unsigned long ulBase, unsigned char*pulData)
{
while(!(HWREG(ulBase + SSI_O_SR) & SSI_SR_RNE))
{
}
// Read data from SSI.
*pulData = HWREG(ulBase + SSI_O_DR);
}
Hi Amit,
Of interest - poster had "no need" to check the SPI Frame Format while, "bit banging." So long as his signals met the slave's demands - all proved "well." (whatever "well" was!)
Then - upon moving to "real SPI" - the need for Frame Format is (suddenly) enforced - and poster is stuck!
Hi Amit,
Amit Ashara said:The configuration requires the call of the functions GPIOPinConfigure and GPIOPinTypeSSI. Please refer to an example code like some in D:\ti\TivaWare_C_Series-2.1.0.12573\examples\peripherals\ssi
Secondly, I do not see CS being configured as a GPIO or from SSI-2 FSS signal neither XDAT0
As you told that SSI2 have not been configured , but it is not the case what i did is sufficient to run SPI. I am getting SPI clock i checked it on CRO.
ADS1271 ic's datasheert says that we should read output on falling edge of clock.
Is it compulsory to put data before get ? Because there is no need of MOSI pin for ads1271 (there is no need of put data on ads1271 ic)
Please suggest me any solution.
Regards,
Sagar
Hello Amit,
Amit Ashara said:Yes. It is necessary for the Master to Put data to get data. Can you please paste the updated code, if it does not look something like the following?
As you told that it is necessary to put data to get data , but in my case there is no need to put data. According ads1271 datasheet as if i will put data then clock will be driven by master and then there will be data lost. As datasheet says that data will change on falling clock.
So in my case i dont want to drive a master clock during data put. (for avoiding data loss). So what should i do , i dont want to drive master clock during data put.??
Regards,
Sagar