SAMD51 - ADC Reference selection

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

 

We want to choose the internal voltage reference via API. Through code we have written into the REFSEL of bits of REFCTRL register  to select internal reference.

 

As per datasheet, configure the INTREF value need to set values in the SEL bits of VREF register of SUPC.

 

19.8.7 Voltage References System (VREF) Control

45.8.6 Reference Control

 

So we have set the INTREF value as 2.5V by calling following API

 

hri_supc_write_VREF_SEL_bf(hw ,0x07); 

 

And then We have chosen internal reference by calling the following API, 

 

 adc_async_set_reference(&ADC_0 , 0x00); 

 

But we are unable to get 2.5V in ADC channel, instead of 2.5V we are getting 3.3V in channels. 

Are we missed anything in configuration? 

 

In datasheet we have found that, 

 

 Bit 2 – VREFOE Voltage Reference Output Enable 
Value Description 
0 The Voltage Reference output (INTREF) is not available as an ADC input channel. 
1 The Voltage Reference output (INTREF) is routed to an ADC input channel.

,so we tried to set this bit to set internal voltage reference but we couldn't set / write this bit. 

 

please provide your inputs on these issues.

Karthi

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can do with the synchronous driver as follow:

 

	switch(componentSelect)
	{
		case AR3_ADC:
		/* AR3 Thumbswitch */
			adc_sync_enable_channel(&ADC_0, AR3_CHANNEL);
			adc_sync_set_inputs(&ADC_0,AR3_CHANNEL,0x18,0);
			adc_sync_read_channel(&ADC_0, AR3_CHANNEL, sLotusAnalogVals.AR3ThumbswitchVals, 2);
			adc_sync_disable_channel(&ADC_0, AR3_CHANNEL);
		break;

		case HALL_THUMB_SWITCH_ADC:
		/* Hall Thumbswitch */
			adc_sync_enable_channel(&ADC_0, HALL1_THUMB_CHANNEL);
			adc_sync_set_inputs(&ADC_0,HALL1_THUMB_CHANNEL,0x18,0);
			adc_sync_read_channel(&ADC_0, HALL1_THUMB_CHANNEL, sLotusAnalogVals.hallThumbswitch1Vals, 2);
			adc_sync_disable_channel(&ADC_0, HALL1_THUMB_CHANNEL);

			adc_sync_enable_channel(&ADC_0, HALL2_THUMB_CHANNEL);
			adc_sync_set_inputs(&ADC_0,HALL2_THUMB_CHANNEL,0x18,0);
			adc_sync_read_channel(&ADC_0, HALL2_THUMB_CHANNEL, sLotusAnalogVals.hallThumbswitch2Vals, 2);
			adc_sync_disable_channel(&ADC_0, HALL2_THUMB_CHANNEL);
		break;

Where 0x18 is the selected reference.

 

Regards,

N.