I've been using Arduino IDE for about 2 years and programming UNO, Leonardos and Nanos with it.
Now I've put an Atmega MCU chip on my own PCB and want to use the IDE to program it. When using the UNO, it was common to use the UNO pin numbers to gain access, for example const int clockPin = 13;
On the Atmega the clockpin is pin 19 on port PB5 and is called SCK. Can I use any one of those parameters when I program the Atmega directly, that is can I say "const int clockPin=PB5" or =19, or =SCK?
I've tried using the port names PB3 and PB5 for example and it compiles without error.
I'm programming via the ICSP port and using the "Upload using Programmer" in the IDE. I uploaded a program that ran in an UNO this way...and it worked, so I know my hardware works.
When you are running the Arduino IDE, then you use the ATmega328P as if it is an Arduino Uno board. Therefor the pin numbers are Arduino pin numbers. Pin 13 is pin 13 (the pin with the led).
Some labels are defined and can be used. For example SDA, SCL, SS, MOSI, MISO, SCK, A0, A1, A2 ... A5.
These labels are defined by Arduino.
When you use the Arduino IDE, then all the low level things that came with the 'avr' branch of the compiler are available as well. So you might have PORTB, PB5 and so on. They are not pin numbers.
You can not use the pin numbers of the microcontroller. There is no compiler that will accept it. The compiler knows for example bit 5 of PORTB.
See your board as a Arduino Uno, since you are using the Arduino IDE.
You can do this:
const int clockPin = 13; // Arduino pin number
const int clockPin = SCK; // Arduino has already defined the SCK of the SPI bus.
The third option is not declaring 'clockPin', but using 'SCK' directly in your code.
For AVR, the names that read like 'PB5' are not pin names as mentioned above. They express bit offsets in the port that they belong to.
hence you will not find them in the pins file: