AnsweredAssumed Answered

SPI reading issue in ADIS16480

Question asked by sayed on Sep 9, 2014
Latest reply on Sep 9, 2014 by NevadaMark

Hi,

 

I am using TIVA LM4f232 eval kit to read sensor values from ADIS16480.

While reading through SPI I am able to get correct data only when I am sending twice the read command.

After initialization, when I am sending read command to read the mag-x register value on First iteration ADIS is throwing 0xff in place of actual mag-x value . Only in second time sending of read command, micro-controller able to receive mag-x register value (previous one).

 

in short, ADIS able to send the data only in second read cycle.

Is there anyway I will receive correct data on same read command.

 

Below is the part of code that I am using for reading of SPI data:

 

int read_spi(int32_t i32Char_1)

{

uint32_t  ulDataRx[NUM_SSI_DATA];

 

int i=0;

 

int32_t i32Charp;

int32_t i32Charr;

uint8_t u1DataRx1[4];

uint32_t u1DataRx2[4];

uint32_t u1DataRx3[4];

ulDataRx[0]=0XFFFF;

 

 

i32Charp=((i32Char_1)&0xffff0000)>>16;

 

i32Charr=(i32Char_1)&0x0000ffff;

 

 

while(SSIBusy(SSI0_BASE));

     

     SSIDataPut(SSI0_BASE,i32Charp); //0x8003); // for accessing pageID

     

     while(SSIBusy(SSI0_BASE));

      

      SSIDataPut(SSI0_BASE, i32Charr); //for reading SPI

      

      SSIDataGetNonBlocking(SSI0_BASE,&u1DataRx2);

      

      SSIDataGetNonBlocking(SSI0_BASE,&ulDataRx);

            

      while(SSIBusy(SSI0_BASE));

       

            u1DataRx1[0] = (ulDataRx[0]&0x000000ff);

            u1DataRx1[1]= ((ulDataRx[0])&0x0000ff00)>>8;

           u1DataRx1[2]= ((ulDataRx[0])&0x00ff0000)>>16;

           u1DataRx1[3]= ((ulDataRx[0])&0xff000000)>>24;

 

          USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,(uint8_t *)u1DataRx1, 2);

              

          USBBufferFlush((tUSBBuffer *)&g_sTxBuffer);

          

    }

Outcomes