This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC for battery measurment and ports 26,27 and 28

Hi,

I am using ADC without external reference and no analog input in order to measure the battery level with a timer (code at the end).

I am also reading several ports state using the buttons library.

Everything works fine, except ports 26, 27 and 28 when I am actually turning the ADC on, even tough I am configuring the NRF->CONFIG to not use any analog input. (And the case about port 28 is even more rare, since it is just a regular IO)

What am I doing wrong?

Thanks!

init code: static void bams_adc_init(void) { /* Enable interrupt on ADC sample ready event*/ NRF_ADC->INTENSET = ADC_INTENSET_END_Msk;
sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);
sd_nvic_EnableIRQ(ADC_IRQn);

NRF_ADC->CONFIG	= (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos) /* Bits 17..16 : ADC external reference pin selection. */
								| (ADC_CONFIG_PSEL_Disabled << ADC_CONFIG_PSEL_Pos)					/*!< No analog input as analog input. */
								| (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos)							/*!< Use internal 1.2V bandgap voltage as reference for conversion. */
								| (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) /*!< VDD specified by PSEL with 1/3 prescaling used as input for the conversion. */
								| (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos);									/*!< 8bit ADC resolution. */ 

/* Enable ADC*/
NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;

}

Related