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.

PGA970: ADC_Handler function

Part Number: PGA970

Hi Scott,
i'm having some trouble reading the ADCs. I'm using the ADC_Handler function in order to do that. As far as I understand this function uses this command:  "demod1 = (DEMOD1_DATA >> 8); //read 16bit ADC1 value" to read the 4x 1Byte of DEMOD1_DATA1 ... DEMOD1_DATA4. With the command the 8Bits of DATA4 become irrelevant and 24Bits remain. But the varaible "demod1" is only able to handle 16bit so its missing the value of DATA1.
This causes a value of 0 in my DAC_Value and DAC_REG0.


These are my configs for ADC and DAC:

ADC_Config(0x05, 0x05, 0x01, 0x08, 0x08);
DAC_Config(0x01, 0x00, 0x11);

My goal was to read the ADC values of S1 and S2 on PGA970 and work with them further on. Could you help me with that?

  • Hello,

    I will have to look into the function to refresh myself and get back to you tomorrow. I'm not entirely clear on the question/issue you are seeing. Because the variable used for the demod date is only 16 bits, you end up getting just DATA2-DATA3? Missing DATA1 and DATA4? You may just need to reassign the variable as a long to get all 32 bits. Note, that you should also start reading from the LSB to make sure that the data is all from the same conversion.

    Regards,

  • Hey Scott,

    I realised that the variables demod1 and demod2 are defined as SL and are thatfore capable of containing 4Byte so the whole Values of DEMODx_DATA. What i don't quite understand is if the values would fit in there why would you use the shift opperator if all values would fit. Also why says the command:

    demod1 = (DEMOD1_DATA >> 8); //read 16bit ADC1 value

    demod2 = (DEMOD2_DATA >> 8); //read 16bit ADC2 value

    when demodx is declared as SL shouldn't it be described as 32bit or after shifting 24bit value?

    SL demod1;
    SL demod2;

    For my now existing values DATA3 and 4 seem to remain empty should I consider shifting by 16 instead of 8?

    To the second part of your answer im not sure what you mean with "reading from the LSB" as ADC read im using the given ADC_Handler function. If you refer to reading register/variable values I would like to know how to do that in CCS.

    Regards,