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.

ADC 1158 data read problem

Hi,

   I have recently purchased one ADS 1158 EVM module from TI. I am trying to interface it with our ARM reference board. I was sucessfull in making the SPI communication to work. I am able to read/write adc registers. My current ADC configurations is, 

Register values for address (00- 09) are: 0A,83,00,00,01,00,00,FF,00,9B.

CS,Start,SCLK,DIN,DOUT,DRDY are controlled or interfaced with arm processor.

S1,S2 - are in DAC, GND mode.

With this current configuration, I was expecting it to sample the channel 0 in single ended mode. As soon as I send high signal to start pin, I am able to received interrupts in DRDY pin. But, when I do register read or direct read of ADC data, I am getting some Junk values. I am not sure whether it is some kind of configuration issue or some coding issue. 

I would appreciate any help in this issue. I am pasting my data receive code below. Please let me know if there are some flaws in my code.

 

// Code could be some what messy.. Its writen to check the functionality.. So, please let me know if some thing is not clear.

 

// Called on DRDY interrupt trigger.

uint32_t ADC_Direct_Read(SPI_TypeDef* SPI_PORT_NAME)

{

    uint8_t rx_data=0;

// Status byte read

   // Sending clock for reception.

    ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

    while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

  // actual data reception.

    rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

// Sending the data via serial ( for debug pupose)

    SendChar(HEX[((rx_data&0XF0)>>4)]);

    SendChar(HEX[(rx_data&0X0F)]);

    SendChar(',');

// MSB of data

    ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

    while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

    rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

// Sending the data via serial ( for debug pupose)

    SendChar(HEX[((rx_data&0XF0)>>4)]);

    SendChar(HEX[(rx_data&0X0F)]);

    SendChar(',');

// LSB of data

    ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

    while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

    rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

// Sending the data via serial ( for debug pupose)

    SendChar(HEX[((rx_data&0XF0)>>4)]);

    SendChar(HEX[(rx_data&0X0F)]);

}

 

 

uint32_t ADC_Data_Read(SPI_TypeDef* SPI_PORT_NAME)

{

        uint8_t rx_data,j1=0x00,dummy=0;

        uint32_t rec_data=0;

// Toggle the cs pin.

CS_HIGH();

CS_LOW();

// Command to do register read

        ADC_1158_Transmit_Data(SPI_PORT_NAME,0x30);

        while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

        dummy=SPI_I2S_ReceiveData(SPI_PORT_NAME);

// Status byte reception

        ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

        while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

        rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

        rec_data |= (rx_data & 0xFF);

        rec_data = rec_data << 24;

// Data byte MSB reception

        ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

        while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

        rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

        rec_data |= (rx_data & 0xFF);

        rec_data = rec_data << 16;

// Data byte LSB reception.

        ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);

        while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);

        rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);

        rec_data |= (rx_data & 0xFF);

 

return rec_data;

}

                                                                                                                                           586,1-8       48%

  • Hi Sathyanarayanan,

    Here are a list of places I would start looking to see if you can find the problem.

    - First, verify that you have the correct clock polarity and phasing to make sure that you are using the correct edge of SCLK to read and write from the ADC. Otherwise you will be reading and writing what you are not expecting.

    - Second, read back the registers you are writing to after you write them all to make sure you are correctly communicating with the ADC.

    - Looking at your register settings, it looks like you are setting up the ADC to use auto scan mode and to convert from channel AIN0. In this case, you need to make sure you have AINCOM connected to ground or some known voltage so that you are referencing your input signal to a non-floating node. Otherwise, you will have junk data.

    - Double check that your reference is powered up and stable by using a DMM to probe across the C5 capacitor.

    - Double check that you are properly powering all the necessary supplies for the EVM. Depending on if you are running the ADC bipolar or single supply this may vary. If you are seeing a /DRDY signal I would imagine you have the digital portion (DVDD) of the part powered.

    Other than that, read back the code and convert it to a voltage using the transfer function in the datasheet to see how it compares to that actual input voltage. If you could post what you see, it would give me an idea of what kind of error you are seeing and hopefully give me an idea of where to look next.

    Thanks,

    Tony Calabria



  • Hi Tony,

                Your comments were very helpful. I was able to read the data registers properly. But I am facing one more problem when doing multiple channel read. Please find the details below.

     

    1. I have configured ADC with 2 single mode channels by writing 0x03 to MUXSG0 and 0x00 to MUXDIF and MUXSG1.


    2. After configuration the register contents looks like this.

    Register values for address (00- 09) are: 0A,83,00,00,03,00,00,FF,00,9B.

    3. With these configuration in place, I expect to read adc data of channel 1 and channel 2 alternatively.

    4. Each time I perform data read operation by issuing 0x30 command, I am seeing some randomness in channel data. Like, Some times I see channel 1 result and some times channel 2 result without any particular pattern.

     

    Can you please help me understand this behaviour ? Is there some thing I am doing wrong ?

  • Hi Sathyanarayanan,

    Looking through your register values that you read, you should be enabling channels AIN0 and AIN1. Then, the converter should be alternating between the two channels and outputting the appropriate converted result. /DRDY will indicate when the conversion is complete and new data is updated into the output register. If you are not monitoring /DRDY, it may seem like the output data channel is random. That would be because you are not reading back every time that the output register is updating.

    You have your data rate set to 23kSPS, if that is too fast, you may want to consider slowing it down by setting the appropriate register. Then, I would recommend using /DRDY to trigger when to send your read command.

    Regards,

    Tony Calabria