This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can VDD be measured? (without routing it to an GPIO)

No text. It's a really short question.

So this is a simple example:

	NRF_ADC->CONFIG     = (ADC_CONFIG_RES_8bit                        << ADC_CONFIG_RES_Pos)     |
                      (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos)  |
                      (ADC_CONFIG_REFSEL_VBG                      << ADC_CONFIG_REFSEL_Pos)  |
                      (ADC_CONFIG_PSEL_Disabled                   << ADC_CONFIG_PSEL_Pos)    |
                      (ADC_CONFIG_EXTREFSEL_None                  << ADC_CONFIG_EXTREFSEL_Pos);
					NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;							
					NRF_ADC->TASKS_START = 1;
					nrf_delay_ms(1);
					uint8_t raw_voltage = NRF_ADC->RESULT;
					printf("%3.2fV\n", raw_voltage*0.0140625);

2,88V. nRF51-DK connected via USB. Works.

Parents
  • Yes it is possible.

    When you setup your ADC you have the option to choose VDD on the INPSEL (you can only choose 1/3 or 2/3 of the VDD however..

    check out the nrf51_bitfields.h

    I would config it something like:

    	//Configure ADC
    	NRF_ADC->CONFIG = (ADC_CONFIG_EXTREFSEL_AnalogReference0<< ADC_CONFIG_EXTREFSEL_Pos)	// AnalogRef 0 as external reference
    													| (ADC_CONFIG_PSEL_Disabled<< ADC_CONFIG_PSEL_Pos)	// Disable input pin 
    													| (ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling << ADC_CONFIG_REFSEL_Pos)	// Use VDD/3 as reference
    													| (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling<< ADC_CONFIG_INPSEL_Pos)	// Supply voltage with 1/3 prescaling used as input for the conversion
    													| (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos);	// 8 bit
    

    Notice that I'm using an external reference to measure the VDD, because you have to compare it to something.

  • Thanks! But can't I use the Internal Band Gap reference? (As I wanted to use a 3rd Party Module which has no external reference)

Reply Children
No Data
Related