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.

ADS9224R:Reading data and registers

Part Number: ADS9224R
Other Parts Discussed in Thread: ADS7066

Hello,

we would like to evaluate the ADS9224R. Unfortunately there is no support for C code or is there anything in the meantime.
We have first designed standard functions for SPI. Next we would read and write registers.
According to the datasheet we first have to send a command READ or Write with address and data.

We implemented this function as follows:

void vSendCommand(char cOPCode, char cAddr, char cData) {

int CodeToTransfer = 0, digit;
volatile bool myBit = false;

SPI_CS_Low;

SPI_CONVST_High;

CodeToTransfer = (cOPCode << 12) | (cAddr << 8) | cData;

digit = 0;

do{

myBit = CHECKBIT(CodeToTransfer,digit);

_NOP();

if (myBit){
SPI_SDI_High; //SDA high
}
else {

SPI_SDI_Low; //SDA low
}

SPI_SCK_High; //Clock high
SPI_SCK_Low; //Clock low

_NOP();

}while(++digit < 16);

SPI_CONVST_Low;

SPI_CS_High;

_NOP();
}

Is this correct so far?


Now we would like to read the data from the corresponding register. How do we do that. We had thought of a function "unsigned char ucRegisterData()".

In that we monitor the RDY pin and as soon as the data is ready we would read it. Unfortunately we are stuck here. How do we get the data of the corresponding register.
It would be nice if someone could help us with C code example to jump the first hurdle.

  • Hi Michael,

    Thank you for your post and your interest in ADS9224R. You're right that we do not have example C code for this device, but I will check if we do have it for a similar device.

    Reading register data consists of sending two frames: the command frame and the receive frame. Section 7.6.3 details the command frame structure and opcodes for register read commands. The data on SDI in the next frame can be anything, including NOP.

    Regards,

    Ryan

  • Hi Ryan,

    first of all, thank you very much for your reply.
    If I understand you correctly, so I have to send once with our function "void vSendCommand(char cOPCode, char cAddr, char cData)" the command to read the corresponding register, and
    immediately afterwards a receive frame. Only, how does this look like? On which line do I receive the data? SDI is the input for the AD converter and on SDO-x I only read the converter data, right? I would be glad if you could help me (also with pseudo code). I am already looking forward to your answer.

    With kind regards Michael

  • Hi Michael,

    For now, please take a look at our example C code for ADS7066. These devices are not exactly comparable in terms of speed and performance, but I believe the interface and command structure is similar enough.

    https://www.ti.com/product/ADS7066#software-development

    The register data in the receive frame can be read on either SDO-xA or SDO-xB.

    Regards,

    Ryan

  • Hallo Ryan,

    erstmal danke für den tipp. Ich schaue mir den Code an und melde mich wieder. Erstmal schönes Wochenende. Mit freundlichen Grüßen

    Michael

  • Sorry, now in englisch:

    Hi Ryan,

    first of all, thanks for the tip. I will have a look at the code and get back to you. First of all, have a nice weekend. With kind regards

    Michael

  • Hello Ryan,

    took a little longer, but have some other projects....

    Looked at the code from the ADS7066. So far everything is understandable. Only some questions tuen themselves there on. If you use the
    conversion with "startManualConversions(0,200000);", this means to measure channel 0 with 200ksp. Only the timer is never stopped again. Where are the individual results, since no array exists into which these samples are read. You would get only one result, if you look for readData(data);
    in the IRQ routine of the timer. There is simply a main.c missing that handles this.
    How would something like this look, if I want to measure e.g. 2000 samples with 200ksps?

    best regards Michael

  • Hello Ryan,

    I did some thinking about how the main routine could look like and came up with the following ideas:

    int32_t result[size_array] = {0};
    int32_t iCounter = 0;

    int main(void){

    initAdcPeripherals();

    initADS7066();

    setChannelAsAnalogInput(0);

    startManualConversions(0,200000);

    while(1)
    {
    delay_us(1);
    }

    in the timer ISR I would add the following:

    result[iCounter] = readData(data);

    if(++iCounter > size_array){
      stopConversions();

      delay_us(1); //Breakpoint here
    }

    would this be correct as far as it goes or would you see it differently?

    best regards

    Michael