ATmega88PA programming problem

Hi, all,

My son and summer intern Simon is working on some data acq hardware and firmware. It's working under Arduino, which is sure an easy way in, with all the setup bits and pretty good library code for the hardware devices. However, being USB-serial based, it has no in-circuit debugger, and he got a bit frustrated with doing burn-and-crash development. (He's learning C as he goes along, which is easier when you can see what's going on.)

So, he installed AVR Studio 6 and is trying to use an AVR Dragon programmer board for ISP plus 1-wire debugging.

There's a recurrent problem with this setup that I've run into myself, namely that the device won't enter programming mode, and can't read the signature bytes. It usually can be made to work eventually, but the flakiness is annoying.

The programming cable is a 6-inch ribbon, and the reset pin pull-up is 10k.

Any wisdom?

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs
Loading thread data ...

On a sunny day (Wed, 20 Jun 2012 11:37:53 -0400) it happened Phil Hobbs wrote in :

I am using par port and a flat cable of about a meter to program PICs. I have experienced timing issues when extending this cable to make various adaptors for various boards I made. So I separated the wires in the extension ribbon, and moved one after the other (clock, data) close to the ground wire, With clock close to ground I was OK, clearly data was late :-) The extra capacitance from clock to near ground equals the delays...

Not for beginners I guess, you need a scope too perhaps. Never use a debugger, why? Wrote your code bottom up and test each module, then the bigger stuff. Top down is only for clueless. I do not like Arduino, dunno why.

Reply to
Jan Panteltje

Did you already try to snap a clamp-on ferrite around that 6" cable? Might have to roll it up a bit sideways to get a smaller one around it (will only work if the ferrite has snapped together).

--
Regards, Joerg

http://www.analogconsultants.com/
Reply to
Joerg

Arduino solves the #1 beginner problem, namely that you dive into the docs, write the big mammoth function to set all the config registers, load the program, and then it just sits there and looks at you, because some bit somewhere is set wrong.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

My guess is that there is a big cap on the reset line..... preventing the Dragon from taking control because it takes too long to get a 'enter debug acknowledge' Also:- Does the target chip support 1W debug ? You have to set 'fuse' to enable 1W debug I think... Second problem. AVR studio 6 is Beta and sucks. Stick with studio 4. Third problem Dragon is about as fragile as you can get.

The place to get all AVR answers is AVRfreaks.net....

Reply to
TTman

On a sunny day (Wed, 20 Jun 2012 15:07:47 -0400) it happened Phil Hobbs wrote in :

This is true, but sometimes I think the solution is worse then the problem. A typical example is Android development.... Java, eclipse, whatabloat...

Best is to start with simple init on embedded and flash a LED (software loop). Then you can activate a timer, maybe try read an ADC, do some peripheral stuff. Actually the SECOND thing, after the LED should be RS232 out, and some simple routines to send an 8 bit and 16 bit register as hex or decimal. having that you _have_ your debug. Kids these days want to write great applications right away. Learn to build with bricks before you start on empire state building old Chinese saying ;-)

Reply to
Jan Panteltje

How are the clock fuses set up? Are you trying to use a crystal whithout a crystal? Wrong load capacitance? Is there a diode from reset to vcc? Supply voltage fights/transients/overvoltage? Also, there are certain ways to lock yourself out of ISP mode by setting the wrong fuse bits...

Reply to
Johann Klammer

peripheral stuff.

decimal.

Chinese saying ;-)

Absolutely. But getting some positive feedback from seeing stuff work is amazingly helpful for the motivation and confidence.

The sequence he's been following is:

  1. Arduino blinky
  2. Arduino hello world, talking to Putty over the USB-serial port
2.5. Build and debug a shield on ground plane perfboard with an ADC, DAC, voltage reference, a few LEDs, etc.
  1. SPI control of a DAC, taking a left-justified unsigned int
4 SPI control of a delta-sigma ADC, returning an unsigned long
  1. Sending the 12 LSBs of the ADC back out the DAC and looking at it on a scope
  2. Converting the ADC value to volts as a float, and putting it out as a nicely formatted ASCII string (this took awhile due to the vagaries of Arduino's stdio implementation)
  3. Putting the ADC acquisition in a timer ISR, with volatile globals to talk with the main loop
  4. Writing a simple user interface that accepts commands over the serial port to set the acquisition speed, or to stop acquisition
  5. Add a 2->1 MUX on the front of the ADC, using a 74HC4316 (one switch works as an inverter to make two others alternate)
  6. Make the data-taking alternate between two channels
  7. Add another case to the interface logic to allow you to take one pair of data points on a particular keypress.

The idea is to make a little box to replace taking data by clipboard while manually setting some voltage. (First use is making CV plots of photodiodes.)

  1. Build a plain AVR board with ISP and DebugWire, to replace the Arduino on the other board.

So far, he's been doing great, and having a lot of fun. Not great for my productivity, but you can't have everything at once. We'll get there.

I found a ferrite from another serial cable and installed it on the ISP ribbon, so we'll see if that fixes it.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

The chips are brand new, so they should be running the default 8 MHz internal clock, iirc. There's no bypass on the reset pin at all, and also no diode. Should there be?

Thanks

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

Thanks. I know most of the folks here, though, which helps. I haven't done an AVR project in a couple of years myself, and naturally I'm trying pretty hard not to do it for him.

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

Yo, Phil, let Simon and your son do some soldering as well. Real hardware stuff. It's become a real problem to find people who can do this. Many kids believe if they master the cyber- and virtual worlds all is well. But it ain't.

--
Regards, Joerg

http://www.analogconsultants.com/
Reply to
Joerg

Agreed.

(The two youngsters are actually one and the same person.) He's doing all of this with hardware he's built himself, except for the Arduino Uno he started with, and he's getting rid of that too, pretty soon. It'll be his stuff from soup to nuts. I'd like him to be choosing his own parts and laying out his own PCBs by August, and that looks very possible.

When you and I started out, radio was the ticket, and now it's robotics. If he decides he wants to learn a lot of deep analogue magic, that'll be another summer's worth. (Since his interests seem to get closer to mine with time, he may well want to do that, but it's up to him.)

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

Try that Appnote:

Atmel AVR042: AVR Hardware Design Considerations

Reply to
Johann Klammer

That sounds encouraging. Just imagine, one day when you put your teeth in a jar at night there may be a place on 160 North State Road that has that big sign "Simon's Fiberoptics Werks" or something.

--
Regards, Joerg

http://www.analogconsultants.com/
Reply to
Joerg

Let me think now... If you have the lock bit set on, the next time an attempt to reload the chip will fail unless you do high voltage programming. Which then over rides that.

I do think i've got the chip vender correct, it could be a PIC I am thinking of. Maybe they both do it that way. I haven't done any AVR/ATMEL coding in a while..

Jamie

Reply to
Jamie

Default 'out of the box' AVR is DIV/8 fuse set so the real clock freq is 1M. A lot of newbies miss that. .... Your ISP freq must be

Reply to
TTman

Na, you just erase the dvice before programming. Only time you need HV is if you select the wrong oscillator fuse settings, and even then, there's a quick fix that doesn't need HV. i.e. you select external xtal and there's no external xtal. The CPU never gets off the ground... so just tack any old Xtal across X1/X2 and off you go... simples :)

Reply to
TTman

How are you going to erase it, if you disable ISP?

Reply to
linnix

On a sunny day (Wed, 20 Jun 2012 15:52:11 -0400) it happened Phil Hobbs wrote in :

Chinese saying ;-)

That is why the RS232. You like books, I once had a book 8080 programming by some metalurgy professor. Helped me a lot.

Very nice! I do miss the part about scribbling zeros and ones machine code and entering with dip switches... ;-)

Well future generation, it is nice to be able to pass on some knowledge.

Reply to
Jan Panteltje

Well, there were a few issues, including an inconsistency between the uplevel version of the AVR GNU toolchain and the downlevel (stable) AVR Studio 4.19 that led to all sorts of compile errors referencing library headers like serial.h, and a wiring error on the board, but at this point Simon's board is working OK with the AVR Dragon.

Thanks to all!

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs
Principal Consultant
ElectroOptical Innovations LLC
Optics, Electro-optics, Photonics, Analog Electronics

160 North State Road #203
Briarcliff Manor NY 10510
845-480-2058

hobbs at electrooptical dot net
http://electrooptical.net
Reply to
Phil Hobbs

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.