Initialization function question- reading ARC register

Afternoon!

I am walking through the initialization code that is called from main. I am currently looking that what is enabling the ADC timer (void variantAdcInit(void))

I am a little lost on the polling of the slave register to check for the condition that the slave's bit that reflects the ADC power mode has been changed to what has been requested.

        /* Poll CREG Slave 0 for Power Mode status = requested status */
        while ( (creg = READ_ARC_REG(AR_IO_CREG_SLV0_OBSR) & 0x8) == 0);

From what I understand, there are these ADC Power states:
• “000” – Deep Power Down
• “001” – Power Down
• “010” – Standby
• “011” – Normal Mode with calibration
• “100” – Normal Mode without calibration

Let's say we have requested Standby Mode and we have reached that. Would our comparison not be:
creg = 010 to 0x8

0010
& 1000


0000

But won't this result ALWAYS be 0?

0000 (Deep Power Down)
& 1000


0000

0001 (Power Down)
& 1000


0000

What am I missing?? I feel like it's just something silly that I am not catching. Thanks in advance!

Figured it out. We are comparing to 0x8 because in the slave register, bit 4 gets switched to 1 if the requested power state is the current state. We poll until that changes and we can confirm we are in the power state we desire.

:slight_smile: