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

difference value of mbed analog read and keil adc

FormerMember
FormerMember

Hello,

I am using keil uvision 5.17, sdk 9.0.0 and sd 130.

Once I programmed whole application through mbed,

Then I moved into keil and implemented all function.

but only ADC is not implemented.

in mbed :

analogIn btt(p5);
printf("%d",btt.read_u16());

result = about 740

in keil :

void adc_config(void)
{
  const nrf_adc_config_t nrf_adc_config = NRF_ADC_CONFIG_DEFAULT;

  // Initialize and configure ADC
  nrf_adc_configure( (nrf_adc_config_t *)&nrf_adc_config);
  nrf_adc_input_select(NRF_ADC_CONFIG_INPUT_6);
  nrf_adc_int_enable(ADC_INTENSET_END_Enabled << ADC_INTENSET_END_Pos);
  NVIC_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_HIGH);
  NVIC_EnableIRQ(ADC_IRQn);
}

void ADC_IRQHandler(void)
{
  nrf_adc_conversion_event_clean();
  adc_result = nrf_adc_result_get();
  nrf_adc_stop();
  printf("%d",adc_result);
}

result = about 510

I got this value same sensor, chip and environment.

How can I fix this difference?

I wanna get same value with mbed or the fomular of 510 to 740.

Thanks,

TY

Parents Reply Children
No Data
Related