Using the new ATMEGA328PB

When using ATmega328PB and mapping those extra pins, this is probably a good opportunity to map PB7/XTAL2 and use that as a regular I/O pin, and make the standard thing to do use an oscillator instead of a crystal. It is OK that an oscillator does not cost the same as a clod of dirt like a crystal does, because you're enjoying the extra pins and various other additional features.

dmjlambert:
When using ATmega328PB and mapping those extra pins, this is probably a good opportunity to map PB7/XTAL2 and use that as a regular I/O pin, and make the standard thing to do use an oscillator instead of a crystal.

Fair enough, but would it kill Atmel to write this down explicitly in the datasheet or the "What's different" document? Or maybe they figured it's Microchip's problem now :smiley:

dmjlambert:
It is OK that an oscillator does not cost the same as a clod of dirt like a crystal does, because you're enjoying the extra pins and various other additional features.

At ~$1 per extra pin, I doubt this is such an awesome deal... what other advantages are there?

Also, any tips for soldering oscillators by hand? Most of the models seems to have only those poor little pads at the bottom... :frowning:

igendel:
what other advantages are there?

I guess the only advantage I can think of is getting to use the ATmega328PB reliably and so john1993 can have his foot-long clock leads. :slight_smile:

I see there are oscillators with pads on the bottom that also wrap part way up the side. I think that would be my selection for hand soldering. A little flux and pre-tinned pads and should be fine. This processor will require the hobbyist to get comfortable with SMD anyway, since a DIP version is not available.

$1 per pin for that one extra pin, and all those other pins are practically free! Think of it as a special buy.

I think a PB Pro Mini version may be interesting just for the extra serial port pins, even if none of the other new pins are brought out to headers. And the Pro Mini would probably be fine with a regular crystal, because of the short clock leads. I have not yet bought one of these MCUs to try out. I might find it crappy like john1993 does, or I might like it.

dmjlambert:
I see there are oscillators with pads on the bottom that also wrap part way up the side. I think that would be my selection for hand soldering. A little flux and pre-tinned pads and should be fine. This processor will require the hobbyist to get comfortable with SMD anyway, since a DIP version is not available.

I saw a couple of oscillators with short through-hole leads; not the highest-accuracy (lowest +/-ppm) ones though. I can solder regular SMDs, that's not a problem.

dmjlambert:
$1 per pin for that one extra pin, and all those other pins are practically free! Think of it as a special buy.

Heh, we should say then it's only $0.99, much more convincing :slight_smile:

dmjlambert:
I think a PB Pro Mini version may be interesting just for the extra serial port pins, even if none of the other new pins are brought out to headers. And the Pro Mini would probably be fine with a regular crystal, because of the short clock leads. I have not yet bought one of these MCUs to try out. I might find it crappy like john1993 does, or I might like it.

I got them because of the extra timers. They seem really cool for all sorts of applications... unless you get bit in the b*** by this crystal issue like I did.

dmjlambert:
I guess the only advantage I can think of is getting to use the ATmega328PB reliably and so john1993 can have his foot-long clock leads. :slight_smile:

how else can i manage to have mcu in one room and xtl in another room? lol

seriously i use the long lead test as a way to characterize oscillator performance and reliability. not just mcu either. some circuits like avr low frequency mode and also low power mode can misbehave with fast rise signals nearby or just bringing your finger close. stable configurations may tolerate actually holding your finger or screwdriver on the pin. naturally the latter more desirable.

If either of you has access to a digital scope, it would be nice to see the clock signals. Are they nice sine waves or crappy?

a regular scope probe has significant effect on signals like avr low power clock and in the case of pb tend to stop it dead. its been a while but using diy active probe i saw a very perfectly formed (albeit low amplitude) sine. a sure sign of marginal activity. the strongest clock waveforms are far from sine and closer to square. rail-to-rail generally as seen for chips that have full swing capability like regular m328.

First post, but i've been following any 328pb info as I (foolishly) used it on a new PCB design of mine. Might as well contribute what i've learned thus far.

I tried out the optiboot bootloader from watterott, it doesnt work in the IDE, but I managed to upload it in avrdude using -Ulock:w:0x3F:m instead.

Then I attempted to upload a sketch using FTDI, no dice. Could be something trivial like reversed TX/RX or something on my end, I need to read the datasheet again. I ended up uploading a blink.hex using ISP, and it works(blinks an LED!). I used the internal 8Mhz because I didn't have any low power oscillators in my hardware bin..

Timer 3 has a slight issue when I tried to use output compare. It's not OCIE3A like I expected, but just OCIEA. I looked at iom328pb.h and this also applies to TOIE, OCIEB, ICIE, for timer 3. Timer 1 and 2 are normal (eg. OCIE1A).

Sorry if any of this doesn't make sense, i'm kind of new to arduino/electronics in general.

Then I attempted to upload a sketch using FTDI, no dice.

FWIW, a standard Optiboot at 57600bps works fine on an Atmel 328PB Xplained Mini eval board. It doesn't do 115200, because the mEDBG chip apparently doesn't use the U2X mode on its uart. And putting the bootloader ON to the Xplained mini (through the mEDBG) still seems to require Atmel Studio.

westfw:
FWIW, a standard Optiboot at 57600bps works fine on an Atmel 328PB Xplained Mini eval board. It doesn't do 115200, because the mEDBG chip apparently doesn't use the U2X mode on its uart. And putting the bootloader ON to the Xplained mini (through the mEDBG) still seems to require Atmel Studio.

Not to completely resurrect a dead thread, but I've been attempting to do this exact thing, and have had no success. The bootloader programs fine thru Atmel Studio (7.0), and the board appears in the IDE - but the programmer times out every attempt.

I also burnt different fuse bits and attempted to program through this tutorial, also to no avail. Any advice would be greatly appreciated.

Did the iom328pb.h file end up in avr-libc yet. I'm not sure how those files find their way into avr-libc but it is taking more time than I would expect. Anyway, I would like to give it a try also if it will build now.

Are you using the optiboot AS project to burn the bootloader? I think you need the latest source from gitbub (NOT the "release" zip) to get that. GitHub - Optiboot/optiboot: Small and Fast Bootloader for Arduino and other Atmel AVR chips The "detailed instructions" for bringing up the PB never happened because I didn't finds a way of burning the bootloader without using AS (which is a pretty big leap for an Arduino user.)

Don't forget that even if you use the bootloader that claims to be an ATmega328p, you still need a new boards.txt file to change the upload speed to 57600.

I've been fiddling with these for a while and have something more in line with the thread, I think. The main question, if I remember... Is that costs and chip differences?

When you compare one in a dip package and one in a smd package, I don't think it's much of an equal compare. Most of us can put a dip in a breadboard and use it, not so much with the smd. These are extra costs that most hobbyist can't afford. And at my age, hard to see makes it even harder to solder.

Many of the people trying this stuff have the problem of not understanding what the data sheet is trying to say, just like me. I don't know how many of these things I've bricked, but I've found it's always a fuse or bit set wrong (configuration.) I don't know if it's their English or mine :slight_smile:

Speaking of bricks... I knew I had to solder this guy in to make it do something and then started thinking how do I 'unbrick' this thing? I found nothing in the data sheet about a HVSP (like in the ATtiny13) that lets you fix a fuse you hosed up and then found it dead...

I know it shows the PP programming in HV mode. I have a Atmel Dragon (actually two of them) and one is configured (wired) for the 328p HVPP mode. I can unbrick 328p with it, no problem. It just shows you how many times I've bricked these things to have a separate programmer. By the way this is over 20 connections for the HVPP programmer (see photo.)

So how do I unbrick a 328pb if it's in circuit? If I can't program it (because it's bricked) after I hose it, do have to pitch it? Like so many have done their Arduinos, not knowing. I'm not going there either. I couldn't afford it! At least with that Arduino, it's in a socket.

Anyone done this (bricked/unbricking) or found something that I missed? Let us know!

I appended a photo of both Dragons. The one on the right is for the HVPP and the left is for the ATtiny13. Left one is ISP'd to the 328p on the breadboard (gray cable over right side of ZIF socket.) Most of my breadboards use the internal 1 MIP clock, as I'm kind of a Minimalist.

I'm still researching this myself. If the thread stays alive, I'll watch it and add if I can...

Thanks... I appreciate everyone's input. Take care...

Jack

the most common cause of "bricking" is mis-configuring the clock, which can usually be fixed by injecting a clock signal into the XIN input. If you turn off ISP programming or RESET, then you're pretty-much screwed.

not understanding what the data sheet is trying to say,... it's always a fuse or bit set wrong

I always use something like AVR® Fuse Calculator – The Engbedded Blog to test my understanding of the datasheet.

Figured I would weigh in here...

Ive had great luck using the 328PB on a custom PCB that I designed. Im using the Elektor Uno R4 bootloader and it works perfectly. My design needed the extra I/O's that the 328PB has, so I spent some time tinkering and got it working.

You have to install the Elektor boards, and Arduino 1.6.7 seems to be the most reliable version. Ive had numerous issues with later versions, so I just stick with 1.6.7.

Once you install the Elektor R4 boards, you'll have to burn the Elektor R4 bootloader onto the blank 328PB chip to take advantage of the 328PB's extra features.

I wasnt able to get the Arduino IDE to flash the Elektor 328PB bootloader properly, so I use WestfW's Optiloader program installed on a separate regular Uno development board to burn the bootloader onto my custom PCB that has the 328PB on it.

HOWEVER....I had to hack the Optiloader program to slip the special Elektor R4/328PB bootloader hex in there, so Optiloader actually burns the proper Elektor R4/328PB bootloader and not a regular 328P bootloader.

After countless hours of reading and messing around with various methods to get the 328PB working as an actual 328PB (with the extra 328PB features), I have found the Elektor R4 setup to be the easiest by far for a noob like me. So if you have gotten frustrated with the 328P/PB thing and trying to get it to work with Arduino, I highly recommend using the Elektor R4 bootloader, and the Optiloader program that I custom modified here.

See attached...

***note: I have not actually tried the 328PB's second SPI, second UART, and touch sensor inputs, however I have used the additional 328PB digital I/O's (like on A6/A7, that are ADC-only on the 328P, but are multipurpose on the 328PB) and they now work perfectly.

Ben

optiLoader.h (1023 Bytes)

optiLoaderR4.ino (25.6 KB)

What about this effort here?

I left an "issue" message asking about steps to burn bootloader.

westfw,

If one just wants to use these 328PBs as 328P, would your optiloader work just fine burning optiboost to these chips?

You said something like making alias for 328PB to be treated as 328P.

I'm thinking about buying maybe 100 of these chips instead of 328P for new boards I reflow. They will act like 328P on these boards. For new designs, I'm interested in using them for what they are so I can get the second serial port :slight_smile:

FYI, deals on the 328PB:

https://forum.arduino.cc/index.php?topic=449384.0

liudr:
What about this effort here?

GitHub - watterott/ATmega328PB-Testing: Atmel/Microchip ATmega328PB support for Arduino IDE

I left an "issue" message asking about steps to burn bootloader.

The optiboot bootloader on that page works fine for me, I can confirm that Timer 3 works, which is a 328PB-only feature. Can't comment on any other features as I've not used them in my code yet.

I burned the bootloader using Arduino as ISP and avrdude, here was my cmd line for fuse settings, although I think I could have made the bootloader section smaller, (256 words instead of 512, according to the watterott page -will test again shortly)

-c arduino -p m328pb -P COM8 -b 19200 -v -D -e -U flash:w:"C:\optiboot_m328pb.hex":a -U lfuse:w:0xFF:m -U hfuse:w:0xDA:m -U efuse:w:0xF5:m -U lock:w:0x3F:m

After that I sucessfully uploaded various sketches via FTDI cable from avrdude and the arduino IDE, about as easy as it gets!

Wasn't there a "somewhat major" vendor who has been selling an "enhanced Uno: with a 328PB?
Oh right; Elektor, as has been mentioned: https://www.elektor.com/elektor-uno-r4 0 it has some other nice features too.
It's a shame they aren't passing along cost reductions to the users (I guess they don't have enough volume...)

This is not correct - the UNO R3 regulator is good for 150mA.
Maybe I'll do a competing board, with FTDI for USB and the extra IO brought out to a header placed like my 1284P board.

DC Current for 3.3 V Pin
50 mA

I'll give it a try. Got myself 20 chips but didn't have time to transplant one of them to a nano yet. I'm more interested in the second serial port and the second I2C bus. I can then have more ADC chips. With a single I2C bus I can only use 4 ADS1115 without some I2C switch IC. The second serial works nicely as xbee, gps, or BT port. It's a pity that if I use the second serial, I won't be able to use SPI or SPI0 since RX1 and TX1 ARE MISO0 and MOSI0. So no sd card unless I can use SPI1.

CR,

My designs are all for niche markets. This PB will be rather nice since I can now add a GPS to my existing data logging devices (I can't use software serial since I need accurate timing for a comm protocol). I'm not confident that if one makes an arduino compatible board with enhanced PB, it would be well received. Nanos are going at $3 each, shipped. Why bother with a few extra pins and ports if you can just get more Nanos or a MEGA for $10.