Offline
Newbie
Karma: 0
Posts: 28
|
 |
« on: November 17, 2012, 02:38:16 am » |
Hey all, I'm using an ATMEGA328P in one of my projects and am having a slightly big issue. I have an 8MHz resonator attached to the XTALI/O pins of the AVR, the same resonator that's used in the Arduino Pro. I was using the AVR ISP MKII along with AVR Studio and read in the factory set fuse bits. Then I changed the low fuse bit to 0x05, thinking this would set the chip to use the resonator. Boy, was I wrong. AVR Studio then gave me the error that fuse programming failed, and now I can't really do anything with the chip (note, regular .hex flash programming was working fine beforehand) I read various articles online and tried debugging with avrdude at a slow speed, and below is the output: > avrdude -p m328p -c avrispmkii -P usb -B5 -F
avrdude: stk500v2_command(): command failed avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00 avrdude: initialization failed, rc=-1 avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x000000 avrdude: Yikes! Invalid device signature. avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude done. Thank you.
I read that high voltage programming would fix this up, but the ATMEGA328P is soldered professionally on the board in the QFN package, so unsoldering is not really an option. And it was pretty expensive to have the board manufactured and assembled. Also, when I designed the board, I only added an ISP header. Is there a way I can recover this chip while it's in-circuit? I greatly appreciate any help. Thanks a lot, Aakash
|
|
|
|
« Last Edit: November 18, 2012, 11:43:35 pm by Aakash »
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Online
Shannon Member
Karma: 129
Posts: 10374
|
 |
« Reply #1 on: November 17, 2012, 03:03:10 am » |
Clock output on PORTB0; [CKOUT=0] ...is now enabled. What is connected to B0?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #2 on: November 17, 2012, 03:09:34 am » |
If by B0 you mean PB0 (ICP), there is nothing connected to it except a male header pin. Should I do something with this pin?
Thanks!
|
|
|
|
« Last Edit: November 17, 2012, 03:23:15 am by Aakash »
|
Logged
|
|
|
|
|
United Kingdom
Online
Faraday Member
Karma: 144
Posts: 4866
|
 |
« Reply #3 on: November 17, 2012, 03:25:41 am » |
Programming the low fuse byte should not prevent you from programming via ICSP. Did you program the high fuse byte as well? If not, then most likely your resonator is not oscillating. You appear to have programmed the CKSEL bytes for a crystal or resonator in the frequency range 0.9 to 3.0 MHz (CKSEL 3..0 = 1010), whereas you are using a 8MHz resonator.
If you have an oscilloscope, then you can check whether you have a clock signal on the CKOUT pin. If there is no signal, then I suggest you disconnect the resonator and feed a clock signal to the XTAL1 pin. That should allow you to reprogram the fuse bytes.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Global Moderator
Dallas
Online
Shannon Member
Karma: 129
Posts: 10374
|
 |
« Reply #4 on: November 17, 2012, 03:31:35 am » |
If by B0 you mean PB0 (ICP), there is nothing connected to it except a male header pin. Should I do something with this pin? Connect an LED + current limiting resistor. If the LED lights, the resonator is running. If the resonator is running, you can reprogram the processor; it's just a matter of getting the ISP bitrate low enough. If the LED does not light, the resonator is not running and you will have to follow @dc42's advice: remove the resonator and provide a clock signal on XTAL1. @dc42: Does the resonator have to be removed? Will it be damaged by a clock signal on XTAL1?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 225
Posts: 14081
Lua rocks!
|
 |
« Reply #5 on: November 17, 2012, 03:36:20 am » |
...am having a slightly big issue ... A small issue? You have set the "divide by 8" fuse. If you slow down programming you can probably talk to it.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 225
Posts: 14081
Lua rocks!
|
 |
« Reply #6 on: November 17, 2012, 03:36:51 am » |
Does the resonator have to be removed? No.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #7 on: November 17, 2012, 03:40:11 am » |
@Coding Badley - the system runs at 3.3V, when selecting the current limiting resistor should I account for that voltage or a lower one?
@dc42 - I have Saleae Logic analyzer, should I be able to use that to test if there is a signal being outputted?
@Nick - Should I go lower than -B5 rate?
Thanks for the help everyone!
Aakash
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Online
Faraday Member
Karma: 144
Posts: 4866
|
 |
« Reply #8 on: November 17, 2012, 03:40:42 am » |
Connect an LED + current limiting resistor. If the LED lights, the resonator is running. If the resonator is running, you can reprogram the processor; it's just a matter of getting the ISP bitrate low enough.
Don't you need to connect the LED+resistor between the pin and ground, and then between the pin and Vcc, and check it lights in both cases? I wouldn't like to guess what state the CKOUT pin will have when there is no clock. @dc42: Does the resonator have to be removed? Will it be damaged by a clock signal on XTAL1?
I don't think there is any danger of damaging the resonator if you leave it in place. However, the resonator will present quite a low impedance at frequencies that are not very close to its resonant frequency, and the signal from XTAL2 will provide negative feedback via the resonator to XTAL1. So it may be difficult to provide enough drive from the clock source, unless you match the resonator frequency. I guess it's worth trying with the resonator connected first.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 225
Posts: 14081
Lua rocks!
|
 |
« Reply #9 on: November 17, 2012, 03:45:54 am » |
@Nick - Should I go lower than -B5 rate?
-B5? I set mine to run at 128 KHz and could reprogram it with -B250. So, no. @dc42 - I have Saleae Logic analyzer, should I be able to use that to test if there is a signal being outputted? I don't think that's relevant. Have you reprogrammed the high fuse by any chance?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Online
Shannon Member
Karma: 129
Posts: 10374
|
 |
« Reply #10 on: November 17, 2012, 03:55:06 am » |
@Coding Badley - the system runs at 3.3V, when selecting the current limiting resistor should I account for that voltage or a lower one? 3.3V.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Online
Shannon Member
Karma: 129
Posts: 10374
|
 |
« Reply #11 on: November 17, 2012, 03:59:03 am » |
Connect an LED + current limiting resistor. If the LED lights, the resonator is running. If the resonator is running, you can reprogram the processor; it's just a matter of getting the ISP bitrate low enough. Don't you need to connect the LED+resistor between the pin and ground, and then between the pin and Vcc, and check it lights in both cases? I wouldn't like to guess what state the CKOUT pin will have when there is no clock. Ooh. Good point. LED needs to light both ways around to ensure the clock is running. @dc42: Does the resonator have to be removed? Will it be damaged by a clock signal on XTAL1? I don't think there is any danger of damaging the resonator if you leave it in place. However, the resonator will present quite a low impedance at frequencies that are not very close to its resonant frequency, and the signal from XTAL2 will provide negative feedback via the resonator to XTAL1. So it may be difficult to provide enough drive from the clock source, unless you match the resonator frequency. I guess it's worth trying with the resonator connected first. Is a series resistor between the clock source and XTAL1 pin necessary? A good idea?
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Online
Faraday Member
Karma: 144
Posts: 4866
|
 |
« Reply #12 on: November 17, 2012, 03:59:28 am » |
@dc42 - I have Saleae Logic analyzer, should I be able to use that to test if there is a signal being outputted?
I'm not familiar with that device, but if you connect one of the channels to the CKOUT pin, then it should give you a frequency readout for that channel if there is a clock signal there.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
United Kingdom
Online
Faraday Member
Karma: 144
Posts: 4866
|
 |
« Reply #13 on: November 17, 2012, 04:03:51 am » |
Is a series resistor between the clock source and XTAL1 pin necessary? A good idea?
As I've very little idea what sort of impedance the resonator will present, I would use one for safety, but only 100 ohms or so.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #14 on: November 17, 2012, 04:13:18 am » |
Nick, I tried using -B250: avrdude -p m328p -c avrispmkii -P usb -B250 -F
avrdude: stk500v2_command(): command failed avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Unknown status 0x00 avrdude: initialization failed, rc=-1 avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x000000 avrdude: Yikes! Invalid device signature. avrdude: Expected signature for ATMEGA328P is 1E 95 0F
And regarding the high fuse question, I'm pretty sure. All I did was read in the fuse bits from the fresh chip and change the low bit by hand in AVR Studio. Though, I always could be mistaken. @dc42 - I don't think CKOUT is outputting anything (see attached screenshot)
|
|
|
|
|
Logged
|
|
|
|
|
|