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:

  • The Serial and Serial1 objects 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.
  • pinMode, digitalRead, and digitalWrite should work on every I/O pin (including A6, A7, SDA1, and SCL1).
  • analogRead should work on every analog pin (A0 through A7).
  • analogWrite should 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:

digitalWrite(SDA1, HIGH);

“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.

Note: If you upload using an ISP programmer, you will erase the A-Star’s bootloader. If you want to switch back to programming the board with its serial interface, you will need to burn the bootloader as described in Section 5.

Related Products

A-Star 328PB Micro - 5V, 16MHz
A-Star 328PB Micro - 5V, 20MHz
A-Star 328PB Micro - 3.3V, 8MHz
A-Star 328PB Micro - 3.3V, 12MHz
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors