ATmega88PA programming problem

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
On a sunny day (Wed, 20 Jun 2012 11:37:53 -0400) it happened Phil Hobbs

Quoted text here. Click to load it

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.

Re: ATmega88PA programming problem
Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
On a sunny day (Wed, 20 Jun 2012 15:07:47 -0400) it happened Phil Hobbs

Quoted text here. Click to load it

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 ;-)

Re: ATmega88PA programming problem
Quoted text here. Click to load it
peripheral stuff.
Quoted text here. Click to load it
decimal.
Quoted text here. Click to load it
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.

3. SPI control of a DAC, taking a left-justified unsigned int

4  SPI control of a delta-sigma ADC, returning an unsigned long

5. Sending the 12 LSBs of the ADC  back out the DAC and looking at it on
a scope

6. 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)

7. Putting the ADC acquisition in a timer ISR, with volatile globals  to
talk with the main loop

8. Writing a simple user interface that accepts commands over the serial
port to set the acquisition speed, or to stop acquisition

9. 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)

10. Make the data-taking alternate between two channels

11. 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.)

12. 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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
Quoted text here. Click to load it

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 /

Re: ATmega88PA programming problem
Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
Quoted text here. Click to load it


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 /

Re: ATmega88PA programming problem
On a sunny day (Wed, 20 Jun 2012 15:52:11 -0400) it happened Phil Hobbs

Quoted text here. Click to load it
Chinese saying ;-)
Quoted text here. Click to load it

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


Quoted text here. Click to load it

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


Quoted text here. Click to load it


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


Re: ATmega88PA programming problem
Quoted text here. Click to load it

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 /

Re: ATmega88PA programming problem

Quoted text here. Click to load it


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



Re: ATmega88PA programming problem
Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
Quoted text here. Click to load it

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



Re: ATmega88PA programming problem
Quoted text here. Click to load it
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
We've slightly trimmed the long signature. Click to see the full one.
Re: ATmega88PA programming problem
Quoted text here. Click to load it

Try that Appnote:

Atmel AVR042: AVR Hardware Design Considerations


Re: ATmega88PA programming problem
Quoted text here. Click to load it
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


Re: ATmega88PA programming problem
Quoted text here. Click to load it

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 :)




Re: ATmega88PA programming problem
Quoted text here. Click to load it

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


Re: ATmega88PA programming problem
Quoted text here. Click to load it

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 <1/4 ck and probably the same for 1W debug ( though
I've never used 1W debug)



Re: ATmega88PA programming problem
Quoted text here. Click to load it


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
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline