WLR089 X PLAINED PRO - Manage to make ADC work

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Board: WLR089 X PLAINED PRO
IDE: Microchip Studio
 
 
I have a LoRaWAN solution where I need to get the analogic values of one port in order to send the battery voltage.
 
I would like to have some help on the ADC process. I'm not sure how can I select the Channel in order to get a value from a specific pin that have ADB function. 
 
Code:

 
struct adc_config conf_adc;
 struct adc_module adc_instance;
 
adc_get_config_defaults(&conf_adc);
 
 conf_adc.clock_source = GCLK_GENERATOR_1;
 conf_adc.reference = ADC_REFERENCE_INTVCC1;
 conf_adc.clock_prescaler = ADC_CLOCK_PRESCALER_DIV16;
 conf_adc.differential_mode = true;
 //conf_adc.positive_input = ADC_POSITIVE_INPUT_PIN16;
 //conf_adc.negative_input = ADC_NEGATIVE_INPUT_GND;
 
 adc_init(&adc_instance, ADC, &conf_adc);
 
 adc_enable(&adc_instance);
 adc_start_conversion(&adc_instance);
 
 
 uint16_t result;
 
do {
 /* Wait for conversion to be done and read out result */
 } while (adc_read(&adc_instance, &result) == STATUS_BUSY);
 printf("result: %d",result);
 

  
I can get the ADC value, but not sure from which channel, if I change the positive input and negative input doesnt change at all the results. 
 
Could you guys help me on that?

André Braga