Arduino Nano with ATmega 328PB and Arduino IDE support

I did not notice that i bought Arduino clone with ATmega328PB not with the ATmega328P, there is CH340C USB-UART chip. 328PB version is newer chip, some kind better than old.

Main disadvantage that chip is not supported by Arduino IDE and it came with unsupported bootloader to load sketches via Arduino IDE (even with added support to 328PB).

I tried to flash new bootloader via USBasp but i can’t change fuse bits. Fuses stays as it was!
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0xff
avrdude: verification error; content mismatch

Somehow i have disabled SPIEN (it enable serial programming and data downloading) and i could not program it via ICSP anymore. I got error but 328pb will be alive:
avrdude: auto set sck period (because given equals null)
avrdude: error: program enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.

Recover atmega 328 fuse bits

I have MiniPro Tl866 programmer that support atmega 328p programming. It not support 328PB, it has difference timings for programing but it works if you choose 328P.

But i could set fuse bits! You have to connect all pins like on scheme down below.

Then before you click program you have to connect XTAL1(PIN9) to pin 7 and XTAL2(PIN10) to pin 8 of 328PB (you have to touch it with small wires for 100ms of programming, do not need to solder).

Uncheck check ID. Set Config an click Programm with checked Config fuse bits and Lock bits:


Now we have to flash bootloader.

328pb Arduino IDE support and bootloader

We will use MiniCore that supports 328PB chip. On Arduino IDE 1.8.7 we can add support for this board in easy way. Open File > Preferences and add extra url for Board Manager:
https://mcudude.github.io/MiniCore/package_MCUdude_MiniCore_index.json
Then go to Tools > Board > Board Manager and install MiniCore by MCUdude.

Now we can choose our board in tools:
Board: Atmega328
Bootloader: Yes
Clock: 16MHz external
BOD: 2.7v
Compiler LTO: Disabled (you can enable it if you need)
Variant: 328PB

Connect your programmer (i’m using usbasp) and choose Burn Bootloader.

Done, now you can write sketches via usb!

If something is still wrong you should set fuse by tl866 again or try this: For example open boards.txt from “C:\Users\user\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1”
change
328.bootloader.unlock_bits=0x3f
to
328.bootloader.unlock_bits=0xff
Save & close the file.

You can use minicore for all 328p boards as well!

Done. Now we have fully functional 328PB with Arduino IDE.

2 Comments

  1. Daniel Fernandes

    10.12.2019 at 22:09

    I did not understand correctly; I have some questions:

    1) Can the Programmer be the Arduino ISP?
    2) And how to make connections from Arduino Uno to Nano?
    3) After doing this procedure, how to record a sketch in Nano?

    Thank you

  2. Daniel Fernandes

    11.12.2019 at 00:21

    I used as a Programmer: “Arduino As ISP”.
    I connected the 6 Arduino Nano ICSP pins to the Arduino Uno but presented the following:

    avrdude: Version 6.3-20171130
    Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
    Copyright (c) 2007-2014 Joerg Wunsch

    System wide configuration file is “C: \ Users \ Daniel \ AppData \ Local \ Arduino15 \ packages \ MiniCore \ hardware \ avr \ 2.0.3 / avrdude.conf”

    Using Port: COM4
    Using Programmer: arduino
    Overriding Baud Rate: 19200
    avrdude: stk500_recv (): programmer is not responding
    avrdude: stk500_getsync () attempt 1 of 10: not in sync: resp = 0xf8
    ……….
    ……….
    avrdude: stk500_recv (): programmer is not responding
    avrdude: stk500_getsync () attempt 10 of 10: not in sync: resp = 0xf8

    avrdude done. Thank you.

    Error writing bootloader.

    I also changed boards.txt as mentioned.

Leave a Reply