22. Arduino Chips¶
The Arduino project introduces people to both hardware and software design. This package hides a massive amount of detail, and bends some of the basic C/C++ approaches to program execution. Here are a few details you need to know.
The main program (project) is called a ‘sketch’ and has a .ino extension.
A program called foo with its foo.ino file must reside in a directory called foo (with out the .ino extension).
Any other .h or .cpp file that is in the foo directory will be automatically scanned, compiled and linked to form the main program. This is what FS1 does.
External packages are processor-dependent. They are managed by the “Preferences” and the “Tools/Manage Library” sub-menus.
Some packages have the same name and may the IDE may confuse itself.
GCC error messages are pretty cryptic – but with practice you sorta get used to them.
Arduino does not use a ‘sketch’ language – it uses C++11 without exception handling. The C++ features try/throw/catch are disabled and cause issues.
Arduino uses a lot of hidden build tricks that are unfamiliar to experienced C/C++ programers using blaze, make, cmake.
See the FS1 makefiles for decent (hopefully) particulars.
Some other things to note:
The definitions vary between the Nano 33 BLE/IoT and the XIAO processors. Beware.
22.1. CLI¶
Follow the instructions:
Arduino chips come in several flavors. Here we are using Arm -Core Arm processors.
Download the Arduino IDE (here 1.8.15)
Under File -> Preferences
Into the Additional Boards Manager URLs enter:
“https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json”
Tools -> Board -> Boards Manager
Search/select Seeed SAMD Boards (see that it includes Seeeduino XAIO M0, and install it. (here 1.21.1) Takes a beat.
The real trick is to start with the raw IDE and add the Blink program. This shows the ‘loop’ is closed with respect to development.
22.2. Pin Outs¶
1Pin Funcion Type Description
21 D13 Digital GPIO
32 +3V3 Power Out Internally generated power output to external devices
43 AREF Analog Analog Reference; can be used as GPIO
54 A0/DAC0 Analog ADC in/DAC out; can be used as GPIO
65 A1 Analog ADC in; can be used as GPIO
76 A2 Analog ADC in; can be used as GPIO
87 A3 Analog ADC in; can be used as GPIO
98 A4/SDA Analog ADC in; I2C SDA; Can be used as GPIO (*)
109 A5/SCL Analog ADC in; I2C SCL; Can be used as GPIO(*)
1110 A6 Analog ADC in; can be used as GPIO
1211 A7 Analog ADC in; can be used as GPIO
1312 VUSB Normally NC;
1413 RST Digital In Active low reset input (duplicate of pin 18)
1514 GND Power Power Ground
1615 VIN Power In Vin Power input
1716 TX Digital USART TX; can be used as GPIO
1817 RX Digital USART RX; can be used as GPIO
1918 RST Digital Active low reset input (duplicate of pin 13)
2019 GND Power Power Ground
2120 D2 Digital GPIO
2221 D3/PWM Digital GPIO; can be used as PWM
2322 D4 Digital GPIO
2423 D5/PWM Digital GPIO; can be used as PWM
2524 D6/PWM Digital GPIO; can be used as PWM
2625 D7 Digital GPIO
2726 D8 Digital GPIO
2827 D9/PWM Digital GPIO; can be used as PWM
2928 D10/PWM Digital GPIO; can be used as PWM
3029 D11/MOSI Digital SPI MOSI; can be used as GPIO
3130 D12/MISO Digital SPI MISO; can be used as GPIO
- Note: (12)can be connected to VUSB pin of the USB connector by shorting
a jumper Power In/Out
22.3. Logical¶
Pins are “overloaded” in their ability; Use of some pins precludes blocks of use.
11 D13 Digital GPIO
23 AREF Analog GPIO Analog Reference
34 A0/DAC0 Analog GPIO ADC in/DAC out
45 A1 Analog GPIO ADC in
56 A2 Analog GPIO ADC in
67 A3 Analog GPIO ADC in
78 A4/SDA Analog GPIO ADC in; I2C SDA
89 A5/SCL Analog GPIO ADC in; I2C SCL
910 A6 Analog GPIO ADC in
1011 A7 Analog GPIO ADC in
1120 D2 Digital GPIO
1221 D3/PWM Digital GPIO ; can be used as PWM
1322 D4 Digital GPIO
1423 D5/PWM Digital GPIO ; can be used as PWM
1524 D6/PWM Digital GPIO ; can be used as PWM
1625 D7 Digital GPIO
1726 D8 Digital GPIO
1827 D9/PWM Digital GPIO ; can be used as PWM
1928 D10/PWM Digital GPIO ; can be used as PWM
2029 D11/MOSI Digital GPIO SPI MOSI
2130 D12/MISO Digital GPIO SPI MISO
22
23
2416 TX Digital USART TX; can be used as GPIO
2517 RX Digital USART RX; can be used as GPIO
26
27
282 +3V3 Power Out Internally generated power output to external devices
2912 VUSB Normally NC;
3015 VIN Power In Vin Power input
31
3214 GND Power Power Ground
3319 GND Power Power Ground
34
3513 RST Digital In Active low reset input (duplicate of pin 18)
3618 RST Digital Active low reset input (duplicate of pin 13)