Can't communicate with atmega328p/arduino chip - Page 1
Forum section: electronics / general

author: RigorM
author_rank: Contributor
timestamp: June 02, 2015, 02:01:52 pm
content: Hi,I'm playing around with some atmega328p (TQFP32) that I soldered on a breakout board. Everything was working fine.. burned the arduino boot loader with my ASVISP mkII. Also burn a simple sketch to see if the chip was working (blink sketch with LED on pin 13 / PB5). everything OK.For theses tests, I need to change a couple things in the fuses to make it go at 1Mhz and Brownout a 2.7V. So I went tohttp://www.engbedded.com/fusecalc/and started to change a couple of things. burned the fuses and now, I can't communicate with the atmega328p.Every time, I get :QuoteIts probably a timing issue between the programmer and chip but can't seem to resync them again (even with the -B xx flag in avrdude).Anything I can do to reset the chip to its original settings ?Thanks

author: con-f-use
author_rank: Unknown
timestamp: June 02, 2015, 02:42:04 pm
content: You screwed up the fuse bits. I suspect, you used fusecalc for the regular 328 variant, not the p. You can hook up an external signal generator to the clock pin ("XTAL2") and try to supply a 500kHz square wave. With that `avrdude -B250 -U lfuse:w:0x62:m -U hfuse:w:0xd9:m -U efuse:w:0xff:m` should restore it to the factory defaults. If that doesn't work, only a high voltage parallel programmer like thefuse bit doctorcan help you, but that is a pain in the ass with SMD.

author: matseng
author_rank: Frequent Contributor
timestamp: June 02, 2015, 03:28:54 pm
content: Quote from: con-f-use on June 02, 2015, 02:42:04 pmAre you sure that they differ? Because looking athttp://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdfpage 280 and forwards I can't find any differences in the fusebits for 328 vs 328P.But I'd also guess that the OP have fscked up the fusebits....

author: Brutte
author_rank: Frequent Contributor
timestamp: June 02, 2015, 03:35:16 pm
content: QuoteNo RSTDISBL, no fun!

author: RigorM
author_rank: Contributor
timestamp: June 02, 2015, 03:37:22 pm
content: I used the 328p when selecting the device (saw the 2 in the list)hum.. looks like i'm f**ked because I dont have a freq generatorLooks like I need to desolder the chip and put in a new one.

author: amyk
author_rank: Super Contributor
timestamp: June 02, 2015, 03:44:43 pm
content: You can always reset it manually... at least there are fewer bits needed to key in a chip erase followed by a few fuse write commands thanon a PIC.

author: matseng
author_rank: Frequent Contributor
timestamp: June 02, 2015, 04:02:55 pm
content: Quote from: amyk on June 02, 2015, 03:44:43 pmHow? If the RSTDISBL is set then you can't use the normal ISP programming mode, only the High Voltage Parallel mode is supported. If this i done on a tqfp atmega then it's time to, in general they need to be desoldered to be hooked to a HV Parallel programmer. This has happened to me a few times - luckily have have a stash of fresh devices so I can quickly just hot-air off the old chip and solder in a new without any hassle.

author: RigorM
author_rank: Contributor
timestamp: June 02, 2015, 04:32:24 pm
content: I did not set the "RSTDISBL" checkbox on the fuse calculator webpage and the chip is on a homemade breakout board so its converted to a DIP package. Much easier to put on a breadboard like that

author: ralphd
author_rank: Frequent Contributor
timestamp: June 02, 2015, 07:38:13 pm
content: A 555 timer can be used to generate the clock.If you have another working AVR, you could generate a clock using PWM.

author: RigorM
author_rank: Contributor
timestamp: June 02, 2015, 07:53:38 pm
content: Quote from: ralphd on June 02, 2015, 07:38:13 pmThat is a great idea.. good thinking ! ;-)I do have a scope so I can fine tune the output to match a 500Khz freq.Thanks !

author: ralphd
author_rank: Frequent Contributor
timestamp: June 02, 2015, 09:30:53 pm
content: Quote from: RigorM on June 02, 2015, 07:53:38 pmThe clock can be >500khz... Up to 20Mhz is fine.

author: con-f-use
author_rank: Unknown
timestamp: June 02, 2015, 10:12:24 pm
content: It's not that critical, yes. Also be absolutely sure, that it's not a dicky connection, or an interfereing component. Disconnect everything but the micro, reflow all the pins and check with continuity mode on your multimeter.

author: BennVenn
author_rank: Regular Contributor
timestamp: June 02, 2015, 10:45:32 pm
content: The arduino bootloader isnt stk500v2, its v1 (Uno bootloader 328p). Use -carduino with avrdude. Had the same problem setting up a mates a few days ago.

author: RigorM
author_rank: Contributor
timestamp: June 03, 2015, 01:55:21 pm
content: Quote from: ralphd on June 02, 2015, 09:30:53 pmI'm a bit confused here... if I can go upto 20Mhz, why can't I just keep the external xtal I already have on the breadboard (connected to xtal1 & xtal2 with 2x 18pF caps to ground) ?and if I can't keep the xtal, then, should the avrdude flag ( -B )should reflect the (freq given to the chip / 2) ?Thanks.

author: amyk
author_rank: Super Contributor
timestamp: June 03, 2015, 02:14:04 pm
content: It depends what you set the fuses to. Look at section 9.2 of the datasheet linked above. The CKSEL settings need to be consistent with the type of oscillator you have, otherwise it won't work.In serial programming mode the clock needs to be running in order for it to process programming commands - I believe it's because it uses the SPI peripheral for this.

author: RigorM
author_rank: Contributor
timestamp: June 04, 2015, 02:52:36 am
content: Ok, So, I installed another chip and also bricked it LOLBut, this time, I got it to work back.. I used another atmega328p, set the fuse to make it wirk full power (and checked the divide by 8 and the clock output on portB0..Used that pin to feed the signal to the XTAL1 pin (input) and reflash the bricked controller.. and it worked.. so, i'm going to keep the first one and try to redo the same.Thanks to all for the help.. worked like a charm.

author: westfw
author_rank: Super Contributor
timestamp: June 04, 2015, 06:24:41 am
content: Check here for additional info and explanations:http://www.avrfreaks.net/forum/tutsoft-recovering-locked-out-avr