Go Down

Topic: How to use 328PB as a Arduino uno? (Read 1 time) previous topic - next topic

Budvar10

#30
Oct 17, 2018, 01:06 pm Last Edit: Oct 17, 2018, 01:33 pm by Budvar10
Reply to #28:
The content of both files is the same. The difference is in HEX format. While the first has 16 bytes of data per row, the second one has 32. See e.g. Intel HEX description on  Wikipedia for more.

The bootloader begins at address 0x7E00 (read version) which is exactly for 512kB boot region so it is there. To ensure to start the bootloader at MCU reset, the fuses have to be set correctly.

PS: I suppose that the PB and P are same internally, aren't?
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

Budvar10

Does Wattuino-pro-mini-PB-5V-16MHz support Arduino IDE uploading?
Yes, sure, but it has no direct USB connection: "To program the board you need an USB TTL adapter or a FTDI Breakout, because the board itself has no USB port."
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

ron_sutherland

DTR reset trick is a concern...

https://github.com/watterott/ATmega328PB-Testing#reset

If the USBuart that you are using has 3V3 logic (e.g. the DTR and RTS handshake pins) then it may not trigger a reset with a 328pb but will with a 328p.

The fuse needs to be set correctly, the 328p and 328pb are nearly the same, but not exactly.

https://github.com/MCUdude/MiniCore/blob/746d6daa74b42d1c5afb74f0f4addbac93c4982f/avr/avrdude.conf#L2412
I use an R-Pi Zero on an RPUpi shield to have a tool-chain at the network edge.

Zumii

Thank you Budvar10 and Ron! Since the bootloader is there, I will check the reset voltage and fuses. Meanwhile, I will buy one of the Wattuino for testing as well.

Zumii

#34
Oct 19, 2018, 08:19 am Last Edit: Oct 19, 2018, 08:20 am by Zumii
I made some progress since I changed the Reset Voltage from 3.3 to 5v. Finally, the Reading part is working and start to enter the Writing phase. However, it showed the message "avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x0c" .

Code: [Select]
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\pcdalao\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.0.1/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328PB
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 6.2
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9516 (probably m328pb)
avrdude: reading input file "xxx\Temp\arduino_build_643567/PCBA_tester.ino.hex"
avrdude: writing flash (9314 bytes):

Writing |
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x0c
#avrdude: stk500_cmd(): programmer is out of sync
avrdude: stk500_recv(): programmer is not responding

ron_sutherland

Maybe it is time to sort out the bypassing (e.g. the little .1uF capacitors that are scattered around integrated circuits). What does your setup look like, any chance we can see an image.
I use an R-Pi Zero on an RPUpi shield to have a tool-chain at the network edge.

Budvar10

#36
Oct 19, 2018, 01:10 pm Last Edit: Oct 19, 2018, 01:10 pm by Budvar10
Quote
...I changed the Reset Voltage from 3.3 to 5v...
?
Carefully, mixing 5V and 3.3V you can damage the chip!

Could you provide setup schematics or picture? And also, it is good to see the log include used command.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

Zumii

Sorry for the delay, here is the layout picture of the board.

According to what Ron suggested, I double checked the capacitor around the circuit and find nothing abnormal.

Capture Picture
Y1-16mhz oscillator, C1-C2 12pf capacitor ,C6-C7-C3-C8 0.1uf capacitor.



Zumii

#38
Oct 22, 2018, 12:28 pm Last Edit: Oct 22, 2018, 12:30 pm by Zumii
Does it have anything to do with Oscillator or Resonator??
I mean Crystal Oscillator is used on Uno board and Resonator-SMD 1:1 is used on ProMini Board. Is there any difference?

Budvar10

Hard to say something from incomplete PCB picture you've posted. You should post the schematics. Also, connections between programmer and board.
Crystal and resonator require different fuse settings - see the datasheet.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

hansibull

#40
Oct 22, 2018, 09:26 pm Last Edit: Oct 22, 2018, 10:30 pm by hansibull
First of all, we need to see your schematic. This will make it way easier for us to troubleshoot. I use Altium Designer at work, so I'd like to look at your layout if you mind sharing the project files (a zip file would be great).

Second, Don't expect the external oscillator to work as well on the 328PB as it does on the 328P. 328PB doesn't support a full swing option, and is way more sensitive to poor PCB layout.

I've designed a development board I use for testing MiniCore compatible microcontrollers in TQFP32 and QFN32 packages. I can confirm that MiniCore works if the hardware is right. I'm sure others also have used MiniCore for their 328PB hardware at 16 MHz.

Third, how are you even able to set fuses/burn bootloader with that board? According to the PCB layout picture you posted pin 16 and 17 isn't connected to anything.


If you have an oscilloscope you should try to probe the XTAL1 pin to see if the oscillator is oscillating like it should. You can also try replacing the crystal capacitors to 22pF. Atleast my 328PB devboard is running fine at 16 MHz with 22pF caps, even though the crystal is located about 4cm away from the MCU. However this value heavily depends on the properties of the crystal.
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

ron_sutherland

#41
Oct 22, 2018, 09:53 pm Last Edit: Oct 22, 2018, 11:15 pm by ron_sutherland
Which crystal are you using? If it is something like a CX5032GB16000H0PESZZ then I think that seems good.

I try to have ground under and around the crystal traces, so there is plenty of improvements that can be made.

Also, the C6 and C7 bypass are too far away and right next to each other so... I guess I need to explain what the bypass capacitor does.

Everywhere the power supply traces run act like an antenna resonate structure, they tend to be resonant at specific frequencies. There are analogies to bridge building. The Tacoma Narrows Bridge collapse was what they use to show in physics classes. To work properly the bypass capacitor needs to be placed at the ends of the power distribution traces, and scattered along the trace (e.g. at each IC is good). To keep a bridge from resonating we might add weights to the tension cable to shift its resonant frequency (though I'm not a bridge designer).

The bridge still falls apart, unfortunately. The disturbances happening at individual bypass elements don't dissipate and can build up. In electronics, the disturbances cause current to flow and that can induce current eddies in ground planes which is dissipative.

Bypass capacitors are useless next to each other. Space them out and make sure there are ground planes so the currents between them can magnetically couple.

@hansibull: that crystal run? what are you thinking, was that to prove a point?
I use an R-Pi Zero on an RPUpi shield to have a tool-chain at the network edge.

Budvar10

@hansibull
Quote
328PB doesn't support a full swing option
You reminded me of this fact, which I have already read.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

hansibull

#43
Oct 22, 2018, 10:28 pm Last Edit: Oct 22, 2018, 10:32 pm by hansibull
Quote
@hansibull: that crystal run? what are you thinking, was that to prove a point?
It was a big design mistake I did before I knew the 328PB lack the following option. However it did infact work on the 48PB, 88PB and 328PB (all bough from Digikey). This design is no problem if the MCU supports full swing, but in this case it's very risky indeed.

Quote
Everywhere the power supply traces run act like an antenna, they tend to be resonant at specific frequencies. There are analogies to bridge building. The Tacoma Narrows Bridge collapse was what they use to show in physics classes. To work properly the bypass capacitor needs to be placed at the ends of the power distribution traces, and scattered along the trace (e.g. at each IC is good). To keep a bridge from resonating we might add weights to the tension cable to shift its resonant frequency (though I'm not a bridge designer).
First of all, I'm not trying to defend bad design practices at all. I'm a big fan of doing things "properly". However the AVR microcontroller is very tolerant to _really_ poor designs. I've seen a commercial product where an ATmega328P in a DIP package was soldered on a circuit board without any bypass caps at all! It's just terrible indeed, but it did in fact work.

When designing less advanced PCBs at work I usually stick with the ATmega324P in TQFP44 package. I use a total of four 100nF caps, one located on each side. I make sure the ground return path is short, and that the external oscillator is placed as close to the MCU as possible.

Last winter we tested some of the boards I've designed at a norwegian certification organ (much like UL and Intertek). In the test chamber they radiated radio waves from 30 MHz to 6 GHz with a peak power of about 150W or so. None of the microcontrollers failed during the test, even though some of the boards were two layer design without metal shielding.

What I'm trying to say is that even though one should take the laws of physics into account when designing a PCB this is just a slow 8-bit micro, not a sub gigahertz 1152 pin FPGA with ten different power rails.
MightyCore -  ATmega1284, mega644, mega324, mega164, mega32, mega16, mega8535
Github.com/MCUdude/MightyCore

MiniCore - ATmega8, mega48, mega88, mega168, mega328
Github.com/MCUdude/MiniCore

ron_sutherland

#44
Oct 22, 2018, 11:10 pm Last Edit: Oct 22, 2018, 11:35 pm by ron_sutherland
The AVR is very forgiving. I was not going for a point about RF or high frequency it was more about the power supply itself. The resonant frequency of the power distribution traces can cause problems in the range we are working with. So I think the bypass needs to be done moderately correctly to keep the power supply clean.

Update: I had not considered the option of placing the crystal a little farther away so there is room for bypassing near the MCU. The more I look at it I think that is an important thing to know is an option.
I use an R-Pi Zero on an RPUpi shield to have a tool-chain at the network edge.

Go Up