View Register Settings in Arduino IDE Console

Hello All

I was wondering if anyone could help

I am trying to use the Serial.print function to view the bit states in the configuration registers. This has partly worked. As seen in the picture, I am able to see the states of all the bits in the ADC->ADC_MR register. However, this hasn't worked for all the registers. e.g. I cannot see the value of ADC->ADC_CHER in the serial console set to 0x80 instead in just says 0.

Does anyone know why this method of serial print has worked for the ADC mode register but not the ADC channel enable register?

I am hoping that if this works, then others in the Arduino community can use this method to see what their configuration registers are set to as there is no facility for this in the Arduino IDE for the DUE (as far as I am aware)

void setup()
{

   /* Serial Communications Configuration */
  
  Serial.begin(115200);
  Serial1.begin(115200);

  /* ADC Configuration */
  
  ADC->ADC_MR   |=  0x10000080; //  Mode register - select free running for ADC
                                //  Sets TRANSFER register to 5 ADC clock cycles
  Serial.println(ADC->ADC_MR, BIN); 
  ADC->ADC_CR   =   0x00000002;       //  Control Register - Begin conversions
  Serial.println(ADC->ADC_CR, BIN);
  ADC->ADC_CHER =   0x00000080;       //  Enable A0 = CH7 on ADC
  Serial.println(ADC->ADC_CHER, BIN);

  /* DAC Configuration */
  
  analogWrite(DAC0,0);

}

Problem might be that a prerequisite clock needs to be enabled. Or, maybe the register is write-protected and you need to change that setting. Or, perhaps after writing this register you need to poll a ready bit until it indicates that clock domain synchronization has been completed (that's the way it is when writing some SAMD registers anyway).

Perhaps you can get some ideas by studying how the (open-source) Arduino SAM core handles the ADC.

Due, right? The datasheet says that CHER is a write-only register...

Thank you, I must have missed that. I need to pay more attention to the Read/Write capabilities of the register.

Does anyone know of a way to see what the bits in the registers are set to in the Arduino IDE or is this outside of the IDE's capability?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.