Hi Guys!
SAMD21 has more analog inputs than used in Arduino. I am faced with the necessity to use PB08 and PB09 and read analog values from them. I was so frivolous when I thought I could easily use them. Now I received the PCB I developed and just now realized how awfully mistaken I was.
At least the googling did not return me any useful info.
Guys, does anyone know how to do this? Is there a way to communicate with necessary registers directly in order to get analog readings from PB08 and PB09? Any useful links or whatever?
Thank you ad stay healthy!
Hi newcomer777,
On the SAMD21 it's possible to use PB08 and PB09 as analog inputs.
Which pins are used for analog input depends on your custom board's "variant.h" and "variant.cpp" files. The Arduino Zero for example uses PB08 and PB09 for analog inputs A1 and A2 respectively and allows for the use of the Arduino "analogRead()" function without the requiring any register manipulation.
Hi MartinL!
Thank you for your comment. I know this, but I am forced to use MKR GSM 1400 bootloader. All available analog pins are already in use, and I need more: PB08, and PB09. That is the store. Sorry I did't describe the issue correctly. Is there a chance to use them?
Hi newcomer777,
Fortunately, port pins PB08 and PB09 use the SAMD21's analog channels AIN2 and AIN3 that are unsed by Arduino analog inputs A0 to A6.
In addition, Arduino have also included entries in the MKR GSM 1400 "variant.pp" file for PB08 and PB09, under pin numbers 31 and 32 respectively. Therefore it should be possible to read the analog inputs on these pins by simply calling the Arduino analogRead() function:
analogRead(31); // Read the analog input on PB08
analogRead(32); // Read the analog input on PB09
Hi MartinL!
Thank you for your help! You are absolutely right - it really works!
Thanks a lot for sharing your knowledge with others! +1