BeagleBone-GPIO icon indicating copy to clipboard operation
BeagleBone-GPIO copied to clipboard

Analog read needs adc_init call, maybe run ADC in continuous mode? Averaging seems wrong bits?

Open Richsl opened this issue 4 years ago • 0 comments

Changed these lines in gpio.c map[(ADCSTEPCONFIG1-MMAP_OFFSET)/4] = 0x00<<19 | ADC_AVG16<<2 | 0x01;

the averaging is set by bit 2-4 (TRM 12.5.20) not 0-2 and I changed the mode to 01 = SW enabled, continuous. With one-shot the call to analogRead() returns the value from the previous call to analogRead(), in continous mode you get the current value. There may be a better way to do this.

Also there needs to be at least one call to adc_init() in the setup otherwise the above does not get set. I assumed that this line would do it, but it was not calling adc_init(), because I guess the clock was already enabled.

if(map[(CM_WKUP_ADC_TSC_CLKCTRL-MMAP_OFFSET)/4] & CM_WKUP_IDLEST_DISABLED) adc_init();

Richsl avatar Mar 08 '21 06:03 Richsl