Author Topic: Can't communicate with atmega328p/arduino chip  (Read 3245 times)

0 Members and 1 Guest are viewing this topic.

Offline RigorM

  • Contributor
  • Posts: 28
Can't communicate with atmega328p/arduino chip
« on: June 02, 2015, 02:01:52 pm »
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 to http://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 :

Quote
avrdude: stk500v2_command(): command failed
avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

Its 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

 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 802
  • Country: at
Re: Can't communicate with atmega328p/arduino chip
« Reply #1 on: June 02, 2015, 02:42:04 pm »
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 the fuse bit doctor can help you, but that is a pain in the ass with SMD.
« Last Edit: June 02, 2015, 02:46:33 pm by con-f-use »
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: se
    • My Github
Re: Can't communicate with atmega328p/arduino chip
« Reply #2 on: June 02, 2015, 03:28:54 pm »
You screwed up the fuse bits. I suspect, you used fusecalc for the regular 328 variant, not the p.

Are you sure that they differ? Because looking at http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf page 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....
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: Can't communicate with atmega328p/arduino chip
« Reply #3 on: June 02, 2015, 03:35:16 pm »
Quote
Anything I can do to reset the chip to its original settings ?
No RSTDISBL, no fun!
 

Offline RigorM

  • Contributor
  • Posts: 28
Re: Can't communicate with atmega328p/arduino chip
« Reply #4 on: June 02, 2015, 03:37:22 pm »
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 generator :(

Looks like I need to desolder the chip and put in a new one.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6616
Re: Can't communicate with atmega328p/arduino chip
« Reply #5 on: June 02, 2015, 03:44:43 pm »
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 than on a PIC. :D
 

Offline matseng

  • Frequent Contributor
  • **
  • Posts: 564
  • Country: se
    • My Github
Re: Can't communicate with atmega328p/arduino chip
« Reply #6 on: June 02, 2015, 04:02:55 pm »
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 than on a PIC. :D
How?  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  :scared:, 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.
 

Offline RigorM

  • Contributor
  • Posts: 28
Re: Can't communicate with atmega328p/arduino chip
« Reply #7 on: June 02, 2015, 04:32:24 pm »
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 :)
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 442
  • Country: ca
    • Nerd Ralph
Re: Can't communicate with atmega328p/arduino chip
« Reply #8 on: June 02, 2015, 07:38:13 pm »
A 555 timer can be used to generate the clock.
If you have another working AVR, you could generate a clock using PWM.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline RigorM

  • Contributor
  • Posts: 28
Re: Can't communicate with atmega328p/arduino chip
« Reply #9 on: June 02, 2015, 07:53:38 pm »
A 555 timer can be used to generate the clock.
If you have another working AVR, you could generate a clock using PWM.

That is a great idea.. good thinking ! ;-)

I do have a scope so I can fine tune the output to match a 500Khz freq.

Thanks !
 

Offline ralphd

  • Frequent Contributor
  • **
  • Posts: 442
  • Country: ca
    • Nerd Ralph
Re: Can't communicate with atmega328p/arduino chip
« Reply #10 on: June 02, 2015, 09:30:53 pm »
A 555 timer can be used to generate the clock.
If you have another working AVR, you could generate a clock using PWM.

That is a great idea.. good thinking ! ;-)

I do have a scope so I can fine tune the output to match a 500Khz freq.

Thanks !
The clock can be >500khz... Up to 20Mhz is fine.
Unthinking respect for authority is the greatest enemy of truth. Einstein
 

Offline con-f-use

  • Supporter
  • ****
  • Posts: 802
  • Country: at
Re: Can't communicate with atmega328p/arduino chip
« Reply #11 on: June 02, 2015, 10:12:24 pm »
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.
 

Offline BennVenn

  • Regular Contributor
  • *
  • Posts: 160
  • Country: au
    • BennVenn's site
Re: Can't communicate with atmega328p/arduino chip
« Reply #12 on: June 02, 2015, 10:45:32 pm »
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.
 

Offline RigorM

  • Contributor
  • Posts: 28
Re: Can't communicate with atmega328p/arduino chip
« Reply #13 on: June 03, 2015, 01:55:21 pm »
The clock can be >500khz... Up to 20Mhz is fine.

I'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.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 6616
Re: Can't communicate with atmega328p/arduino chip
« Reply #14 on: June 03, 2015, 02:14:04 pm »
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.
 

Offline RigorM

  • Contributor
  • Posts: 28
Re: Can't communicate with atmega328p/arduino chip
« Reply #15 on: June 04, 2015, 02:52:36 am »
Ok, So, I installed another chip and also bricked it LOL

But, 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.  ;D
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3123
  • Country: us
Re: Can't communicate with atmega328p/arduino chip
« Reply #16 on: June 04, 2015, 06:24:41 am »
Check here for additional info and explanations:  http://www.avrfreaks.net/forum/tutsoft-recovering-locked-out-avr
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf