Schematic finally finished - A few questions.....

busonerd:
I think you can do it all single sided - Just rotate + move R2 + R3 and you should be able to continuously route that gnd trace without it deviating too far.

Greetings David,

Good call! Try this:

http://www.stonard.com/SFE/NES2USB_single_DC.jpg

Comments Welcome!

I always return the oscillator ground directly to the nearest MCU ground pin with it’s own track - it reduces emissions. It doesn’t matter very much for a one-off, of course, but I’ve got into the habit of doing it.

I always ground the USB connector, and put a copper pour area under it.

Leon

Thanks for everyone’s input on this little project, looks like that board should work. Also looks like I need to learn more about routing :slight_smile:

Guess that will come with time!

Routing definitely comes with time - just lots of practice. Eventually you just “see” the new paths / ways to adjust things… Its just doing for hours and hours and hours ;).

Cheers,

–David Carne

etched the board last night and managed to rescue all the components from the last attempt :slight_smile:

Still got to source some headers for the sockets on the boards though, might go and see what Maplins has to offer today but i’m not holding out much hope …

Can anyone point me in the direction of a popular and simple AVR programmer? Preferably one that features ISP as well as a socket? USB would be nice but not essential!

I have built a simple LPT flasher but for some reason it won’t allow me to set the high and low fuse values…

The Atmel AVR Dragon?

Leon

That looks good, but I was after building one myself :slight_smile:

Think i’m going to go with the USBasp at http://www.fischl.de/usbasp/

Looks solid and I should be able to connect a DIL socket to an ISP cable to allow me to program in and out of circuit…

Right, finally managed to get the board working, only thing left to do now is program the Atmega8…

[<LINK_TEXT text=“http://img517.imageshack.us/img517/3336 … cj0.th.jpg”>http://img517.imageshack.us/img517/3336/board1cj0.th.jpg</LINK_TEXT>

And this is causing me more headaches :slight_smile:

I have built a simple LPT AVR flasher using the schematic below…

[<LINK_TEXT text=“http://img517.imageshack.us/img517/420/ … oa2.th.jpg”>http://img517.imageshack.us/img517/420/lptprogrammeroa2.th.jpg</LINK_TEXT>

But I can’t get it to flash the AVR, I am using AVRdude gui with the settings below…

[<LINK_TEXT text=“http://img213.imageshack.us/img213/9677 … ji0.th.jpg”>http://img213.imageshack.us/img213/9677/avrdudesettingsji0.th.jpg</LINK_TEXT>

Can anyone see anything wrong with the schematic above or my AVRdude gui settings that would stop the Atmega8 from being flashed? Of does anyone elso have a similar simple LPT flasher I could build that?

I have a http://www.fischl.de/usbasp/ flasher but this needs a programmed AVR to work :(](ImageShack - Best place for all of your image hosting and image sharing needs)](ImageShack - Best place for all of your image hosting and image sharing needs)](ImageShack - Best place for all of your image hosting and image sharing needs)

konguk:
Right, finally managed to get the board working, only thing left to do now is program the Atmega8…

And this is causing me more headaches :slight_smile:

I have built a simple LPT AVR flasher using the schematic below…

But I can’t get it to flash the AVR, I am using AVRdude gui with the settings below…

Can anyone see anything wrong with the schematic above or my AVRdude gui settings that would stop the Atmega8 from being flashed? Of does anyone elso have a similar simple LPT flasher I could build that?

Greetings konguk,

The diagram and options page are for an Atmel '2313. Does

the program cater to a Mega8?

Have you tried to read the signature and osc. cal bytes from

a blank Mega8 device? Do you have a blank '2313 to try the

same experiment?

Have you confirmed that Vcc is present on the device to be

programmed?

While drawing 5V from the host PC’s parallel port is simple,

it may not work for all PCs. You can always add an external

5V supply.

Comments Welcome!

I’ve checked the volatges and everything seems correct, i even tried it with or without the crystal but still no joy. It does seem to be writing to the chip but constantly gives me this error…

avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude.exe: Device signature = 0x1e9307
avrdude.exe: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file “C:\Documents and Settings\Administrator\Desktop\shiftregister.hex”
avrdude.exe: input file C:\Documents and Settings\Administrator\Desktop\shiftregister.hex auto detected as Intel Hex
avrdude.exe: writing flash (5070 bytes):
Writing | ################################################## | 100% 1.88s
avrdude.exe: 5070 bytes of flash written
avrdude.exe: verifying flash memory against C:\Documents and Settings\Administrator\Desktop\shiftregister.hex:
avrdude.exe: load data flash data from input file C:\Documents and Settings\Administrator\Desktop\shiftregister.hex:
avrdude.exe: input file C:\Documents and Settings\Administrator\Desktop\shiftregister.hex auto detected as Intel Hex
avrdude.exe: input file C:\Documents and Settings\Administrator\Desktop\shiftregister.hex contains 5070 bytes
avrdude.exe: reading on-chip flash data:
Reading | ################################################## | 100% 1.42s
avrdude.exe: verifying …
avrdude.exe: verification error, first mismatch at byte 0x0440
0x05 != 0xff
avrdude.exe: verification error; content mismatch
avrdude.exe done. Thank you.

The schematic i’m using says it will work fine with atmega8 AVR’s as long as the pins are matched correctly which they all are…

I’ve finally admitted defeat and ordered a cheap LPT avr isp from http://www.active-robots.com/products/c … ards.shtml

http://www.active-robots.com/products/c … er-750.jpg

This should hopefully allow me to program the atmega8 using the ISP I have included in my schematic…

fingers crossed!

Sometimes avrdude gives me the same error, especially when I try to program big hex files. It seems like it loses sync with the mcu, probably because of signal inegrity issues in my home made programmer. Anyway, simply retrying programming multiple times (2 or 3) solves this issue.

It’s a wierd one, the Atmega is definetly having data written to it, but when I read this data back out to a file and compare it to the original hex it is totally different (hence the verification error i guess :slight_smile: )

My AVR ISP programming cable arrived from www.active-robots.com today so i’m going to try it out with my board.

I’ll post up as soon as i’ve tried it…

I sometimes get strange things happening when I forget to power the AVR (i.e. it gets powered via the parallel port and its inbuilt protection diodes, rather than by a proper 5v supply to Vcc and gnd). Sometimes, the AVR programs perfectly and I realise only when I remove it from the breadboard, I forgot to connect the 5v!

Also make sure you tell avrdude the right AVR part in that drop down box.

I use a simple home made parallel programmer (old printer lead with the end cut off and the relevant wires poked into breadboard, and 1K resistors from there to the right AVR pins) and it works well.

Got the STK200 programmer hooked up last night and burnt the hex file to my atmega8 using avrdude which all went fine…

The circuit still didn’t work because it needs a high fuse and a low fuse setting, as soon as I set these values the chip stopped responding and wouldn’t allow me to do anything with it…

It took me about 8 chips before I realised this was what was happening!

Anyone have any idea why setting the high and low fuse bytes would cause this to happen? The schematic i’m working from informs me that the high byte needs to be set to 0xc9 and the low byte needs to be 0x9f.

Is there a way to rescue the chips that have failed? After doing some reading someone suggested connecting a crystal to the XTAL pin on the atmega to revive it, don’t know how true this is though…

I have also tried to use pony programmer to set the high and low fuses but the software doesnt give me the option to enter the values directly, it just displays a screen like the one below…

[<LINK_TEXT text=“http://img340.imageshack.us/img340/6515 … ap0.th.png”>http://img340.imageshack.us/img340/6515/ponyprog2000fusesap0.th.png</LINK_TEXT>

At least I have made some progress!](ImageShack - Best place for all of your image hosting and image sharing needs)

konguk:
Got the STK200 programmer hooked up last night and burnt the hex file to my atmega8 using avrdude which all went fine…

Greetings konguk,

Isn’t the STK200 an Atmel product? (I have an STK500 and I’m

very happy with it).

konguk:
The circuit still didn’t work because it needs a high fuse and a low fuse setting, as soon as I set these values the chip stopped responding and wouldn’t allow me to do anything with it…

This has happened to me a few times. If you accidently tell the

target AVR to use an ext osc and there isn’t one - it stalls.

konguk:
Anyone have any idea why setting the high and low fuse bytes would cause this to happen? The schematic i’m working from informs me that the high byte needs to be set to 0xc9 and the low byte needs to be 0x9f.

I don’t know off the top of my head. Do you have a copy of the

AVR Studio4 IDE? [Learn more here.

konguk:
Is there a way to rescue the chips that have failed? After doing some reading someone suggested connecting a crystal to the XTAL pin on the atmega to revive it, don’t know how true this is though.

If you have a non-responsive AVR don’t assume the chip is dead.

Connect an external oscillator to the chip and most likely it will

wake up. The ‘fuses’ can be reversed and once the chip is

responding to the ISP you can change it back to int. oscillator, etc.

as desired.

By far the easiest way is to salvage (or buy) a[ TTL Xtal

oscillator (not a crystal, although one is inside), and run it from

a 5V bench supply. A four to ten megahertz unit is good, the

actual frequency is not critical.

There is a built-in clock oscillator on the STK500 that I

link with a jumper, perhaps your STK200 is similar?

Comments Welcome!](http://www.ecsxtal.com/store/pdf/ecs_100.pdf)](http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725)

Just a curiosity, are you trying to do a device similar to the one described in appnote AVR309 from atmel? (A software USB implementation)

Anyway, it seems that the fuses are good: they select an high frequency external crystal oscillator, brown out detect enabled and a good start-up time.

It looks like your crystal isn’t oscillating. Try checking the connections near the crystal, sometimes when soldering on the pcb remains some burnt flux that acts like a 50K…1M resistor, and since the oscillator is an high-impedance circuit it does not work.

To rescue the failed chips you only need a breadboard and a 2…8MHz crystal or better still an oscillator as described from bigglez. Connect the programmer, a power supply and restore the fuses to the default value that can be found in the datasheet.

Sorry for sounding thick, but what is the difference between a crystal and an oscillator??

I am using this programmer http://www.active-robots.com/products/c … ader.shtml

Which as far as I can tell is an STK200 clone

I don’t quite understand the issue with the fuse bytes, the values sepcified in the schematics I have are expressed in a hexadecimal format, is there a way to convert this data into the options that Pony Programmer lets me select?

Are you saying that when I program the Atmega Fuse Bytes I am telling it to allow ISP programming but only with an external crystal? And the fact that my STK200 doesnt have an external crystal is the reason it is no longer responding to any commands?

A crystal is something you find normally in a 2 pin metal can, and on its own won’t do a lot. You need to make an oscillator circuit that uses the crystal to get the square wave you want. The AVR includes this oscillator, so all you need to add is the crystal itself and the load capacitors for the crystal in your circuit.

A crystal oscillator usually refers to a 4 pin device in a metal can that puts out a square wave at the specified frequency.

You can make your own crystal oscillator with a crystal easily enough - an inverter gate, biasing resistor, the crystal, and load capacitors are all you need:

  .               .
 ---             ---
-----           -----
  |               |
  =  C1           = C2
  |               |
  +-----| []|-----+
  |      XTAL     |
  |               |
  +----/\/\/\/----+
  |     R1        |
  |               |
  +-------|>o-----+
          U1      |
                  +-----------> output

C1/C2 are the load capacitors, for a crystal of 6-8MHz probably around 20pF or so. R1 for a 74HCxx inverter is about 200K. You can make it oscillate with a simple inverter made up of a P and N channel mosfet, too.

I get it now! The Atmega8 has in internal oscillator but to use it you need an external crystal as well? Am I on the right tracks?

So if I programmed the Atmel and then set the high and low fuse bytes correctly and the chip is no longer responding to the ISP then would this point to the fact that maybe my 12mhz crystal on the circuit is not funcitoning correctly?

konguk:
I get it now! The Atmega8 has in internal oscillator but to use it you need an external crystal as well? Am I on the right tracks?

Greetings konguk,

Yes, you are. All devices require a clock and for the AVR

devices there are several options. Some AVRs (including

the Mega8) have internal oscillators that require no

external parts. These are limited to 8MHz max. Each

device is calibrated at final test and has a cal byte unique

to that chip.

All AVRs can operate with an external crystal to control

the internal oscillator, and this requires two pins. All

AVRs (AFAIK) can be driven from an external clock,

which requires one pin.

It would be wise for you to download and read the full

[AVR Mega8 data sheet. It’s over 300 pages and even if

you only skim it or need help with details you’ll have a

better handle on what this powerful microcontroller can

do.

konguk:
So if I programmed the Atmel and then set the high and low fuse bytes correctly and the chip is no longer responding to the ISP then would this point to the fact that maybe my 12mhz crystal on the circuit is not funcitoning correctly?

Possibly. Regardless of your application program, the

external crystal should show activity with a scope. This

may not be the case if the AVR “fuses” are set for internal

oscillator, or external oscillator input, or the Xtal pins

are set for general IO function instead of clock.

Comments Welcome!](http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf)