Code Monkey home page Code Monkey logo

Comments (7)

nickgammon avatar nickgammon commented on July 26, 2024

I must admit I haven't actually programmed an ATmega328PB because I don't have one to hand. However after checking the datasheets there don't seem to be any significant differences between the ATmega328P and the ATmega328PB.

Do you have decoupling capacitors between VCC and Gnd, and AVCC and Gnd? Typically you use 0.1 ยตF (100 nF) as close to the chip legs as you can get them. Removing "divide by 8" will, of course, speed the processor up, and then an absence of decoupling capacitors would have a greater effect.

There was a recent issue about this and that person reported that using the decoupling capacitors fixed the problem. Also that was with the ATmega328PB, so it appears there is no programming reason for it not to work.

from arduino_sketches.

ryanoc3ros avatar ryanoc3ros commented on July 26, 2024

Hi Nick,
I appreciate the quick response. I have 100 nF caps as you have described, and checked them to make sure they were soldered correctly. I didn't find any issues there.

I tried to run your Board Detector program again, and strangely, it found the chip this time. I then ran the Board Programmer program, and it seemed to run smoothly, however when trying to load a sketch onto the ATmega328PB, it didn't respond. I ran Board Detector again, and this time, it couldn't find the chip, just like yesterday. Board Detector finds any of my other boards (ATmega2560, ATmega328P, etc) without issue.

I have attached the relevant section of my schematic, perhaps there is something obvious that I am missing.

Thanks for the support!
image

from arduino_sketches.

nickgammon avatar nickgammon commented on July 26, 2024

I can't see anything obvious. Try connecting the external clock (D9 on the Uno) to XTAL1 and see if that helps. Also, next time you can get the chip detector to work, please capture the output (copy and paste the text, don't take a screen shot) and show what you get, in particular the fuse settings.

One other thing you can try is connect a diode between /RESET and +5V. The positive side of the diode goes to /RESET and the negative side (cathode) goes to +5V. A 1N4148 would be fine. That is intended to clamp /RESET to 5V so it doesn't accidentally go into high-voltage programming mode.

screenshot from 2018-04-03 12-54-21

from arduino_sketches.

ryanoc3ros avatar ryanoc3ros commented on July 26, 2024

This gets stranger. So I added a diode between /RESET and 5V and ran both of your programs. It managed to detect the chip and burn the bootloader to it. I then plugged in my FTDI module and uploaded Blink.ino to my board. It seemed to work fine. I then unplugged the board from everything and powered it off of an external power supply, and it no longer blinked. Switching back and forth between the FTDI chip and external power resulted in the same behavior; blinking when hooked up to the computer, no response when on external power. After a few cycles of this, it started behaving strangely when hooked up to the FTDI board. Sometimes it would blink a few times and stop, sometimes it wouldn't blink at all. I ran your Detector and Programmer sketches, and it could not detect the chip anymore, just like before. The outputs from your programs when it initially worked is included below.

Your suggestion about connecting the external clock. Do you mean run a wire from XTAL1 on the master arduino, over to XTAL1 on the slave board?

As a side note, I briefly soldered the more widespread ATmega328P chip on the board yesterday, and everything worked perfectly, so I am fairly confident that power to the board is done properly.

Will this bootloader make the ATmega328PB behave like a ATmega328P? i.e. no second UART, SPI, and I2C interfaces? If so, it might be worth it to just stick with the ATmega328P, unless there is another significant advantage to using this chip and bootloader.

These are the outputs from both your Board Detector and Board Programmer programs.

Atmega chip detector.
Written by Nick Gammon.
Version 1.20
Compiled on Apr 2 2018 at 20:01:56 with Arduino IDE 10805.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x16
Processor = ATmega328PB
Flash memory size = 32768 bytes.
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xF5
Lock byte = 0xEF
Clock calibration = 0x8F
Bootloader in use: Yes
EEPROM preserved through erase: No
Watchdog timer always on: No
Bootloader is 512 bytes starting at 7E00

Bootloader:

7E00: 0x11 0x24 0x84 0xB7 0x14 0xBE 0x81 0xFF 0xF0 0xD0 0x85 0xE0 0x80 0x93 0x81 0x00
7E10: 0x82 0xE0 0x80 0x93 0xC0 0x00 0x88 0xE1 0x80 0x93 0xC1 0x00 0x86 0xE0 0x80 0x93
7E20: 0xC2 0x00 0x80 0xE1 0x80 0x93 0xC4 0x00 0x8E 0xE0 0xC9 0xD0 0x25 0x9A 0x86 0xE0
7E30: 0x20 0xE3 0x3C 0xEF 0x91 0xE0 0x30 0x93 0x85 0x00 0x20 0x93 0x84 0x00 0x96 0xBB
7E40: 0xB0 0x9B 0xFE 0xCF 0x1D 0x9A 0xA8 0x95 0x81 0x50 0xA9 0xF7 0xCC 0x24 0xDD 0x24
7E50: 0x88 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0x09 0x94 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x04 0x04

MD5 sum of bootloader = 0xFB 0xF4 0x9B 0x7B 0x59 0x73 0x7F 0x65 0xE8 0xD0 0xF8 0xA5 0x08 0x12 0xE7 0x9F
Bootloader name: optiboot_atmega328

First 256 bytes of program memory:

00: 0x0C 0x94 0x63 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0xBA 0x0F
10: 0x0C 0x94 0xBA 0x0F 0x0C 0x94 0xBA 0x0F 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00
20: 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0xB3 0x0D
30: 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00
40: 0x0C 0x94 0x69 0x0D 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x37 0x0C 0x0C 0x94 0x11 0x0C
50: 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00 0x0C 0x94 0x8B 0x00
60: 0x0C 0x94 0x74 0x0E 0x0C 0x94 0x8B 0x00 0x00 0x00 0x00 0x08 0x00 0x02 0x01 0x00
70: 0x00 0x03 0x04 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
80: 0x25 0x00 0x28 0x00 0x2B 0x00 0x00 0x00 0x00 0x00 0x23 0x00 0x26 0x00 0x29 0x00
90: 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x04 0x02 0x02 0x02 0x02 0x02 0x02 0x03 0x03
A0: 0x03 0x03 0x03 0x03 0x01 0x02 0x04 0x08 0x10 0x20 0x40 0x80 0x01 0x02 0x04 0x08
B0: 0x10 0x20 0x01 0x02 0x04 0x08 0x10 0x20 0x00 0x00 0x00 0x00 0x24 0x00 0x27 0x00
C0: 0x2A 0x00 0x4F 0x16 0x4A 0x10 0x11 0x24 0x1F 0xBE 0xCF 0xEF 0xD8 0xE0 0xDE 0xBF
D0: 0xCD 0xBF 0x12 0xE0 0xA0 0xE0 0xB1 0xE0 0xEE 0xE3 0xF0 0xE3 0x02 0xC0 0x05 0x90
E0: 0x0D 0x92 0xA2 0x31 0xB1 0x07 0xD9 0xF7 0x24 0xE0 0xA2 0xE1 0xB2 0xE0 0x01 0xC0
F0: 0x1D 0x92 0xA4 0x37 0xB2 0x07 0xE1 0xF7 0x10 0xE0 0xC2 0xE6 0xD0 0xE0 0x04 0xC0

Programming mode off.

Atmega chip programmer.
Written by Nick Gammon.
Version 1.38
Compiled on Apr 2 2018 at 23:40:16 with Arduino IDE 10805.
Attempting to enter ICSP programming mode ...
Entered programming mode OK.
Signature = 0x1E 0x95 0x16
Processor = ATmega328PB
Flash memory size = 32768 bytes.
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xF5
Lock byte = 0xEF
Clock calibration = 0x8F
Bootloader address = 0x7E00
Bootloader length = 512 bytes.
Type 'Q' to quit, 'V' to verify, or 'G' to program the chip with the bootloader ...
Erasing chip ...
Writing bootloader ...
Committing page starting at 0x7E00
Committing page starting at 0x7E80
Committing page starting at 0x7F00
Committing page starting at 0x7F80
Written.
Verifying ...
No errors found.
Writing fuses ...
LFuse = 0xFF
HFuse = 0xDE
EFuse = 0xF5
Lock byte = 0xEF
Clock calibration = 0x8F
Done.
Programming mode off.
Type 'C' when ready to continue with another chip ...

from arduino_sketches.

nickgammon avatar nickgammon commented on July 26, 2024

Your suggestion about connecting the external clock. Do you mean run a wire from XTAL1 on the master arduino, over to XTAL1 on the slave board?

No, I mean run a wire from D9 on the master Arduino (assuming it is a Uno) to XTAL1. The bootloader programmers uses a timer to output 8 MHz on that pin.


Will this bootloader make the ATmega328PB behave like a ATmega328P? i.e. no second UART, SPI, and I2C interfaces?

No, not at all. All the bootloader does is let you upload code. Once the code is uploaded it transfers control to it, or if the bootloader times out (no incoming serial data) after about a second it transfers control to your code anyway.

The bootloader does not, in itself, add or subtract any functionality from your sketch. It's not like a "library" that provides services to running code. You can run code without the bootloader even being there.


Switching back and forth between the FTDI chip and external power resulted in the same behavior; blinking when hooked up to the computer, no response when on external power.

I would be checking your external power supply. Does it supply 5V exactly? What about ripple? Put your multimeter on AC and see what voltage it shows.

from arduino_sketches.

ryanoc3ros avatar ryanoc3ros commented on July 26, 2024

Without changing much, and burning the bootloader again, it seems to take sketches well now. Everything appears to be working. I am not quite sure why it is being inconsistent. Since this is a bug report for your programs, and that side of things seem to be working correctly, I will have to do more research and investigating to make it more stable. I appreciate all the help and advice you provided.

Thanks

from arduino_sketches.

nickgammon avatar nickgammon commented on July 26, 2024

No problem. I use that code frequently to burn bootloaders so I don't think the code itself is at fault. I'll close this as probably a wiring issue.

from arduino_sketches.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.