Hi there,
the ATMEGA1284P has 31 ADC-channels.
In a program I accidentially used a channel number above 31:
A=GETADC(32)
What happened, was that I got totally strange results in the Variable A.
The reason is that BASCOM doesn't counter-check the used channel-number with the maximum that are available in the used chip but simply computes the bit pattern corresponding to the channel number.
In this case the bit-pattern is x100000.
If this bit battern is transferred to the LSBs of the ADMUX register it becomes clear what happened.
Bit5 is set and this bit (ADLAR) does [u:5f8806a7da]left-adjust[/u:5f8806a7da] the 10bit-result in the 16bit ADCL and ADCH result register.
Perhaps there could be a check for the maximum available channels in a future BASCOM version to spare the users what happened to me :-)
Well this check might not be possible if you use a variable for the channel because BASCOM cannot know the content of the variable.
But then it could limit the bits set in ADMUX to the allowed ones and give a hint in the Help-file.
Kind regards
[b:5f8806a7da][color=red:5f8806a7da](BASCOM-AVR version : 2.0.7.6 )[/b:5f8806a7da][/color:5f8806a7da]
↧