1

For some applications I need access to the registers that control the output/input and high/low state of pins. For example pin 10 on a adalogger is PORTB with a mask of _BV(6). This information can be found in pins_arduino.h. For some boards many variants get installed. I turned on verbose compiling and looked through the output there as well as looking through boards.txt and platform.txt. In that output I see an include to a directory with a pins_arduino.h file but there is nothing in that file but a definition for BUILTIN_LED.

When I run a function like digitalWrite(13,HIGH); how does it know which registers to use for pin 13? Since my board has this pin, and digitalWrite(13, HIGH); makes an LED light up ... it's working.

3

In the boards.txt file for the core in question you have a line for each board:

xxxx.build.variant=yyyy

where yyyy is the name of the folder in variants for the board.

For instance, the Uno, has:

uno.build.variant=standard

which relates to:

variants/standard

with the pins_arduino.h file in it for that board.

  • Thanks, I found that line and it agrees with the output from the compiler. The problem is that particular file is basically empty. Does that mean there is a default somewhere that it's using as well? – Matt Oct 30 '17 at 19:53
  • It's far from empty on my installation. What version are you running? And what board / core is it? – Majenko Oct 30 '17 at 19:54
  • I have hundreds of pins_arduino.h files throughout the system. My problem is with the adafruit huzzah ESP8266. The pins_arduino.h file is basically empty. – Matt Oct 30 '17 at 19:55
  • Well, that is down to the core. The core most likely has defaults that don't need overriding. Most ESP8266 boards just map the GPIOs 1:1 and don't need anything else. Remember: an ESP8266 is not an AVR Arduino and does not follow the same rules. – Majenko Oct 30 '17 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.