Device Signature 0x000000, ATMEGA328P-AU - Page 1
Forum section: electronics / general

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 01:06:52 am
content: Hi all,I am currently building a project from Thingiverse...specifically this project....https://www.thingiverse.com/thing:3708466Copy of the schematic can be found here...https://cdn.thingiverse.com/assets/93/15/35/78/c6/Schematic.pdfI am at the stage of uploading the Arduino bootloader via SPI comms to the ATMEGA328 so I can then upload the code via Arduino IDE (UART), however, I am always getting "Device Signature = 0x000000" from avrdude when I try to burn the bootloader. I am using an Arduino UNO as an ISP programmer, I have tried powering my project board from the UNO and from a dedicated power supply to no avail.One thing to note is that the project board does not have any pads or headers broken out to the SPI lines, so I have had to solder some 30AWG, kynar insulated wire directly to the pins of the IC (photo's below).I have also connected the scope while doing the upload and what I can see is that the MISO line (response from project board to the programmer) doesn't go up to 5v, it peaks at 3.84v when high according to the scope. See screenshots below.Yellow= Clock;Pink= MISO;Blue= MOSI;Green= ResetChecked the usual (connections, power, etc, but it is all there)Oh!! One last thing, the 16MHz crystal oscillator isNOToscillating!! When I put my scope probe onto XTAL2 or even XTAL1, the voltage rises to approx 1V, but it is DC, there is not clock signal.I am assuming this is because the microcontroller is still using the internal clock it is set to use from the factory? For completeness sake, I even uploaded the modified ArduinoISP code which creates a 16MHz clock on pin 3 of the Arduino UNO. I have used this in the past to sort problems when the fuses were set incorrectly, but it did nothing for me here.Any suggestions or thoughts which might help?

author: RoGeorge
author_rank: Super Contributor
timestamp: December 14, 2019, 01:50:07 am
content: Did you put the 10uF between the Reset pin and GND of the Arduino UNO (the Reset pin of the programmer board, the Reset found in the POWER section of the connector on a normal UNO board)?Without the 10uF, the programmer board might receive a Reset glitch from the PC (it depends on the operating system and the drivers, it comes from what the DTR/DTS pins on the PC side are acting during programming, sometimes they flip and unintende reset your UNO programmer, the 10uF cope with any reset glitch that may appear during programing).

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 10:40:18 am
content: I do not have a 10uF capacitor, but I have tried with both 100uF & 100nF with no luck. Also, I have programmed other board without a capacitor just fine. From what I have seen the capacitor fixed an issue that was around over 5 years ago, since then it has been fixed within the ArduinoISP code, hence I have had no issues with other projects without the capacitor.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 14, 2019, 11:09:40 am
content: There are only 3 wires shown. One also needs to connect GND. To start programming it usually also needs the Reset pin - so 5 connections minimum.In a reasonable low EMI environment the programming should work without a capacitor at the reset pin. No need for 10 µf, some 100 nF are plenty and even 1 nF should be enough. 100 nF and 100 µF would be decoupling for the supplies.Another point is the lenght of the cables - to avoid ringing the cables should be relatively short, like 50 cm max., better only 30 cm.A new AVR is usually running on the internal (1 MHz, actually 8 MHz divided by 8 ) clock, so the crystal is not yet active. This is good as the connection is less sensitive to ringing with the slow clock.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 11:58:47 am
content: Quote from: Kleinstein on December 14, 2019, 11:09:40 amThe 3 wires shown are only for SPI (SCK, MISO & MOSI), the 5V, GND & Reset attach to the 6-pin header, they are just not shown as connected in the image.As for the capacitor, as I have said, I tried 100nF but still no joy.The length of the cables are approx 15-20cm, so not too long.One image that keeps grabbing my attention is this one....Notice how the MISO line (Pink) comes up on its way to 5V as the reset line (Green) drops, then as the reset recovers the MISO signal begins to fall! Then shortly after the reset line recovers it dips momentarily, and during that period the MISO line jumps up to 5V then drops back down once reset recovers.To me it looks like something related to the reset line is pulling MISO down to just sitting at 3V and if I remember correctly a high value for SPI is VDD x 0.6 which would be 5 x 0.6 = 3V...so the programmer might be seeing all 0's as a response due to the MISO line never getting high enough.The only thing the MISO line connects to is a 74 series IC which controls some LED's. However I did remove this to test and the signal remained identical, so something is pulling down the MISO line in relation to reset, but not sure what.....Or am I going of in the totally wrong direction here? Thoughts?

author: Kilrah
author_rank: Unknown
timestamp: December 14, 2019, 12:06:29 pm
content: 2 of the lines got to LEDs. You'll likely need to disconnect them to be able to flash the bootloader, they will be loading the lines too much.Ideally you should have flashed it before soldering the microcontroller.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 12:47:41 pm
content: Quote from: Kilrah on December 14, 2019, 12:06:29 pmThe lines you talk about go via the 74 series IC, which then drives the LED's. When I remove the 74 series IC and therefore remove the LEDs from the circuit it is still the same??I do not have the tools to program the ATMEGA328 out of circuit, otherwise I would have preferred that option.

author: GromBeestje
author_rank: Frequent Contributor
timestamp: December 14, 2019, 01:20:30 pm
content: When I look at the schematic I see from pin 17 (SCK) -- LED25 -- R25 -- GND.

author: andersm
author_rank: Super Contributor
timestamp: December 14, 2019, 01:22:15 pm
content: Reset is supposed to stay low for the duration of the programming operation. Those pictures look more like it's trying to use the normal Arduino serial bootloader protocol.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 01:44:24 pm
content: Quote from: GromBeestje on December 14, 2019, 01:20:30 pmI have removed the LED on pin 17 and the 74 series IC, still the same...Quote from: andersm on December 14, 2019, 01:22:15 pmInteresting...what could be causing that though?

author: TK
author_rank: Super Contributor
timestamp: December 14, 2019, 01:45:43 pm
content: You might have a bad ATmega328P micro.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 02:03:22 pm
content: I am beginning to wonder that, it was purchased from LCSC who own JLCPCB and are like Digikey or Mouser of China, so I would no expect it to be fake!https://lcsc.com/product-detail/ATMEL-AVR_ATMEL_ATMEGA328P-AU_ATMEGA328P-AU_C14877.html

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 02:23:36 pm
content: Ok...I have another board here with a different IC. I have just burnt a bootloader onto that using the exact same method.Reset line drops low andSTAYS LOWduring the entire process as andersm mentioned. The fact my MISO line drops down when reset goes high is expected. So the issue is reset is going high when it should be kept low.The question is why?!Confident that if I can sort this then it should work.

author: TK
author_rank: Super Contributor
timestamp: December 14, 2019, 03:19:14 pm
content: When reset goes low, SPI clock should start clocking showing SPI activity, I don't see SCK clocking, it just goes low from high and stays low. Also why it is high in the first place? I believe it should be low and active high.

author: TK
author_rank: Super Contributor
timestamp: December 14, 2019, 03:20:37 pm
content: Also check if all the pins are correctly soldered. Sometimes they look soldered but they are floating when looked closely with a magnifying glass.

author: Kleinstein
author_rank: Super Contributor
timestamp: December 14, 2019, 04:07:40 pm
content: AFAIK the reset line should stay low for much longer, there could be a problem with the programmer side.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 06:45:16 pm
content: Quote from: TK on December 14, 2019, 03:19:14 pmHmm, good point, will compare it to how the known working board programs dig deeper into that, however looking at screenshots above it is only at 1V initially, then drops to 0V, but does seem to spike up to 5V during transmissions on the MOSI & MISO lines.Not had the chance to look at these issues since earlier today as my girlfriend broke her toe, so spent the last 4 hours with her.Quote from: TK on December 14, 2019, 03:20:37 pmI am positive the soldering is fine as it was all done under an Amscope Microsope. The ATMEGA was done using the drag soldering method. I have checked the connections with a multimeter also which proves there is an electrical connection and under the microscope it physically looks totally fine.Quote from: Kleinstein on December 14, 2019, 04:07:40 pmNot the programmer, as it works perfectly with the other board I have. Exact same programmer (Arduino UNO as ISP) works perfectly with the other one.However, I do 100% agree that the reset line should stay lower for the entire programming sequence, which it is not doing, so that's an issue.Before having to go to the hospital earlier, I did find something interesting.Basically, when I was trying to program the IC originally I had only soldered all the SMD components which means no LED's, no headers (except the 6-pin one) andno push button tactile switch on the reset line.I decided to solder the tactile switch in place, thinking it would not make any difference as it is a normally open switch...well after soldering the switch avrdude now seesDevice Signature = 0x008000if I do not press the switch (hold reset to GND) during programming, if I hold the switch during programming it changes to Device Signature = 0x000000I need to look at the SCK as mentioned above and also why the reset is not going low and staying low.However that is where I am at right now. Will try to take another look at it later tonight and report back with more info.

author: TK
author_rank: Super Contributor
timestamp: December 14, 2019, 07:40:20 pm
content: The switch should not make any difference when soldered and not soldered. If you solder it in the wrong position, they will be always in closed state. 2 pins are connected to each other, so in the wrong direction you are shorting RESET to be permanently grounded

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 08:05:35 pm
content: Quote from: TK on December 14, 2019, 07:40:20 pmYes, I am aware of that and before soldering I double checked with the multi meter, it is in the correct position and only shorts to GND when the switch is closed. However the device signature is 0x008000 when not closed and 0x000000 when it is closed on a consistent basis.I agree that it should not have made any difference what-so-ever and it's what I expected to happen.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 09:41:52 pm
content: GOT IT WORKING!!The issue was that I was connecting the reset to the 6-pin header which goes HEADER > 100nF Capacitor > RESET on IC, in the end I just connected a wire directly to the RESET pin on the IC and BOOM, it works AND the RESET line goes low and holds low. The capacitor was basically keeping the RESET line held high, hence it dropped down, then would rise up as the capacitor charged up.Feel a bit stupid for not thinking about that earlier, but oh well, at least it's not some major fault.I also now have 16MHz on the external clock.

author: Kilrah
author_rank: Unknown
timestamp: December 14, 2019, 09:43:40 pm
content: You were going through a series cap? Yeah obviously it wouldn't work...Interesting that we all missed that bit where you said you connected to the header and didn't think to check the schematic. To be fair it's definitely not standard to put a series cap on a reset line, so not exactly what you'd expect to find...

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 10:09:53 pm
content: Quote from: Kilrah on December 14, 2019, 09:43:40 pmYeah, the series cap is used when uploading a normal sketch from the arduino IDE and you only want the board to quickly reset so that the IDE can catch it in the bootloader stage and upload the main code....obviously does not work to your advantage when trying to upload a full bootloader and you need reset to be held low the entire time.Oh, and just to add, the bootloader was uploaded with everything else attached (74 series IC, LED's, the lot), so none of that stuff had any effect. Also just uploaded the sketch via Arduino IDE and it worked perfectly using the 6-pin header, even with the cap on the reset line

author: Kleinstein
author_rank: Super Contributor
timestamp: December 14, 2019, 10:31:48 pm
content: I just looked at the schematics, there are a few points that could be made better next time:Ideally there should be another 100 nF cap for the AVCC / AGND pin pair as well. The 100 µF cap at the input side of the SMPS could get quite some ripple current. So this may need to be a low ESR one and maybe a little larger. On the other side the 1000 µF at the output look like rather large.The motor control could profit from a free wheeling diode for the motor (to protect the FET). R36 and R37 should likely be lower value, so this channel could also do PWM. At least for the LEDs one could have chosen a N-FET and have the switch low side.I don't think the timer would need such a high clock speed. So a 2 MHz of 4 MHz crystal could have been fast enough. This reduces possible EMI emissions and power consumption.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 14, 2019, 10:44:42 pm
content: Yeah, you are probably right in that some improvements could be made, but this is just a gift I am making for my girlfriends birthday which is fast approaching, so as long as it works, that's all I'm concerned with just now.Maybe in future if I get to make a similar project from Thingiverse and have more time I can look over it in detail and see where improvements could be made prior to building & ordering parts.

author: TK
author_rank: Super Contributor
timestamp: December 14, 2019, 11:27:25 pm
content: I am glad it worked, but the series capacitor with one end connected to RESET and the other to nothing should not charge and cause any problems. All arduino boards has the 100nF cap in series to one of the control pins of the UART and it still can receive a new bootloader programmed using the SPI pin header without any issues.

author: Nerull
author_rank: Frequent Contributor
timestamp: December 14, 2019, 11:47:14 pm
content: There is no series capacitor between the reset line of the ICSP header and the reset pin of the chip on an arduino.Caps block DC. The reset line needs to be pulled high or low by the programmer to function, a series cap makes this impossible.https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdfThere is a series cap between the atmega16 DTR output and the reset line of of atmega328p, but this is irrelevant to ICSP programming.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 15, 2019, 12:04:00 am
content: Quote from: TK on December 14, 2019, 11:27:25 pmYou are right, but it was not 1 end to reset and the other end to nothing. When I finally got it working that’s how it was connected.When it was not working it was 1 end to reset and the other end to pin 10 (SPI SS line) on the Arduino UNO I was using as an ISP programmer, it was literally in the middle of my circuit which seems to be needed for uploading from Arduino IDE to enter the boot loader, but stops SPI comms working to upload the boot loader in the first place due to allowing reset to quickly rise back up to 5V instead of being held low.

author: Mario87
author_rank: Frequent Contributor
timestamp: December 15, 2019, 12:11:05 am
content: Quote from: Nerull on December 14, 2019, 11:47:14 pmExactly and this 6-pin header is not for ICSP use, it is to be used by removing the ATMEGA328P (DIP socket) from an UNO and then wiring the 6-pin header of my board to the UNO, effectively making my ATMEGA328P (TQFP) part of the UNO, so when I upload a sketch from Arduino IDE the ATMEGA16 resets the ATMEGA328P (TQFP) into the boot loader and then uploads the sketch.To do that it makes use of their series cap, but when you try to use it for ICSP it causes the problems I had.Basically my fault as I was not using the 6-pin header as intended, but in my defence, there was no ICSP provision provided to allow for uploading of the boot loader, so I went a bit maverick by soldering directly to the IC and decided to use the “easily accessible” reset pin on the 6-pin header which was ultimately a mistake.

author: TK
author_rank: Super Contributor
timestamp: December 15, 2019, 12:32:49 am
content: Sorry, I did not know that you were using the Reset pin on the 6-pin header, after the serial capacitor. Know it is clear why it failed.