Welcome, Guest
Username: Password: Remember me

TOPIC: Understanding Arduino Code - Left Adjust ADC?

Understanding Arduino Code - Left Adjust ADC? 7 months 1 week ago #1756

  • rkpx1
  • rkpx1's Avatar
  • OFFLINE
  • New Member
  • Posts: 1
  • Karma: 0
This line of code is found in several of the Arduino sketches:
input = ((ADC_high << 8 ) | ADC_low) + 0x8000;

I am a bit confused, as the ADC is set to be left-adjusted (according to ADMUX = 0x60;). Wouldn't this mean that in order to sum the ADC_high and ADC_low together, the instruction code should be ((ADCH << 2) | (ADCL >> 6))? As the code currently stands, it seems like the ADC should be right-adjusted instead. I am basing this off the ATmega328p datasheet (picture attached), and any clarification would be greatly appreciated!
Attachments:
Last Edit: 7 months 1 week ago by rkpx1.
The administrator has disabled public write access.
Time to create page: 0.492 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio