Send a Registername to a function

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

Hello,

i want to use my function get_adcb like this:

adc_value = get_adcb(2)

to get the value of ADC2

how can i replace CH1 with channel in my function?

static uint16_t get_adcb(uint8_t channel)
{

	ADCB.CH1.CTRL |= 0x80;
	while(!(ADCB.CH1.INTFLAGS && 0x01)); 
	return ADCB.CH1.RES;
	ADCB.CH1.INTFLAGS = 0x01;
}

Günter

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

hint:
configure the ADC using "channel" ( set conversion speed too!)
start the conversion
wait for conversion to finish
return result