4.4. ATmega328PB support in the Arduino IDE
Since the A-Star’s ATmega328PB microcontroller is backward-compatible with the ATmega328P commonly used on Arduino boards (like the Arduino Uno and Pro Mini), existing programs and libraries written for a standard Arduino can be used on the A-Star 328PB without any changes (except to account for clock speed differences when necessary). Also, our Arduino IDE add-on includes support for the new features on the ATmega328PB, making them easier to use from the Arduino environment and allowing the A-Star 328PB to be an upgrade from ATmega328P-based boards.
Here are some details about what Arduino features work when programming the A-Star 328PB in the Arduino IDE:
Serial1objects both work, providing access to USART0 and USART1, respectively.
- The “Default I2C bus” sub-menu in the “Tools” menu allows you to choose whether the Wire library and other libraries like it will use TWI0 or TWI1. There is no library support for accessing TWI0 and TWI1 in the same program. However, you can access the registers for both modules and define ISRs for them.
- The “Default SPI bus” sub-menu in the “Tools” menu allows you to choose whether the SPI library and other libraries like it will use SPI0 or SPI1. There is no library support for accessing both SPI0 and SPI1 in the same program. However, you can access the registers for both modules and define ISRs for them.
digitalWriteshould work on every I/O pin (including A6, A7, SDA1, and SCL1).
analogReadshould work on every analog pin (A0 through A7).
analogWriteshould work on every pin with PWM (including 0, 1, and 2).
The ATmega328PB has two new pins, PE0 and PE1, that have no equivalent on the ATmega328P. These pins do not yet have official pin numbers in the Arduino environment, so if you need to use their pin numbers in your code, we recommend using the constants
SDA1 (for PE0) and
SCL1 (for PE1) that are defined in our header files (instead of using the pin numbers 22 and 23 that we have provisionally assigned). For example:
“Upload Using Programmer”
The Arduino IDE provides the ability to upload a sketch to a board using AVR in-system programming (with a programmer connected to the 2×3 ISP header). This is done by running the Upload Using Programmer command in the Sketch menu. Before running that command, you must select the correct Port and Programmer in the Tools menu. If you are using the Pololu USB AVR Programmer v2.1 for in-system programming of the A-Star 328PB, you should select “Atmel STK500 development board” as the programmer.