Compiling for atmega16 - pin file question

The Arduino pin number is the index of the arrays in that file.

The digital_pin_to_port_PGM array maps Arduino pin numbers to ports. Check the value of digital_pin_to_port_PGM[6]:
https://github.com/sudar/arduino-extra-cores/blob/master/variants/mega16/pins_arduino.h#L110

PD,

So we now know Arduino pin 6 is PORTD.

The digital_pin_to_bit_mask_PGM array maps the Arduino pin number to bit of the port. Check the value of digital_pin_to_bit_mask_PGM[6]:
https://github.com/sudar/arduino-extra-cores/blob/master/variants/mega16/pins_arduino.h#L145

_BV(6),

In this case it is bit 6, but there is no reason it could not be any other bit number, so don't place any special significance on the match between Arduino pin number and bit number.

1 Like