Shop OBEX P1 Docs P2 Docs Learn Events
AVR Programmer — Parallax Forums

AVR Programmer

micahpmicahp Posts: 11
edited 2014-11-25 20:29 in Propeller 1
This is a prop AVR programmer following the AVR910 protocol. It is pretty rough but with a little work it can be cleaned up and made into a proper prop object. I've only tested it on a Atmega168 using avrdude 5.3 on OSX.

To get it to support another AVR processor add the processor code in the ch == "t" area (e.g., ser.tx( $MyCode ) (the specific processor code can be found in the avrdude.conf file).

Hope you find this useful.

Comments

  • AleAle Posts: 2,363
    edited 2008-01-06 07:58
    Have you been able to program the fuses (I did not look into the source) ? (Some avr910 programmers cannot write the fuses reliably)
  • micahpmicahp Posts: 11
    edited 2008-01-06 08:03
    to program the fuses you have to use the "universal" command (the "send" command in avrdude terminal). i am just now researching on exactly how todo this. FYI: this code supports the universal command though i havent tested it yet.
  • micahpmicahp Posts: 11
    edited 2008-01-06 08:48
    to read and set the fuse bits is pretty easy using avrdude terminal "send" command (i.e., "universal" command). just find the serial programming section of the particular processor and there should be a command table. for the atmega168:

    Load Instructions
    Load Extended Address byte(1) $4D $00 Extended adr $00
    Load Program Memory Page, High byte $48 $00 adr LSB high data byte in
    Load Program Memory Page, Low byte $40 $00 adr LSB low data byte in
    Load EEPROM Memory Page (page access) $C1 $00 0000 000aa data byte in
    Read Instructions
    Read Program Memory, High byte $28 adr MSB adr LSB high data byte out
    Read Program Memory, Low byte $20 adr MSB adr LSB low data byte out
    Read EEPROM Memory $A0 0000 00aa aaaa aaaa data byte out
    Read Lock bits $58 $00 $00 data byte out
    Read Signature Byte $30 $00 0000 000aa data byte out
    Read Fuse bits $50 $00 $00 data byte out
    Read Fuse High bits $58 $08 $00 data byte out
    Read Extended Fuse Bits $50 $08 $00 data byte out
    Read Calibration Byte $38 $00 $00 data byte out
    Write Instructions(6)
    Write Program Memory Page $4C adr MSB adr LSB $00
    Write EEPROM Memory $C0 0000 00aa aaaa aaaa data byte in
    Write EEPROM Memory Page (page access) $C2 0000 00aa aaaa aa00 $00
    Write Lock bits $AC $E0 $00 data byte in
    Write Fuse bits $AC $A0 $00 data byte in
    Write Fuse High bits $AC $A8 $00 data byte in
    Write Extended Fuse Bits $AC $A4 $00 data byte in
  • micahpmicahp Posts: 11
    edited 2008-01-06 08:58
    also i should mention there is a trick to the ISP wiring in order to get the MISO of the programmer to work. the SCK needs to be wired as an input (CLK) pin to the prop:

    
     CLK  <---*
                  |
     SCK  ----*------>
     MISO <---
     MOSI --->
     RESET -->
    
    
    
  • AntonSAntonS Posts: 2
    edited 2009-07-11 20:42
    I tried to use this program to program a ATTiny25.

    I use the following options for avrdude:

    avrdude -p t25 -c avr910 -v -P -F com5 -e -U flash[noparse]:w:[/noparse]first.hex

    But I get the following response:

    avrdude: error: programmer did not respond to command: select device

    Does anybody has a clue whats wrong?
  • James NewmanJames Newman Posts: 133
    edited 2009-08-10 18:23
    I've been working on this code, and getting started with AVRs for some USB stuff. Anyway, I tried to program the fuse bits of my ATTINY2313 to use the 20Mhz crystal, and now I have 2 unusable AVRs. I used avrdude, to set the lfuse byte to 0xFF. That should have been external crystal, no clockdiv, and a 64ms startup time. Now I can't communicate with the device at all. My only thought is that theres a bug in the universal command portion of the software. I havn't looked at it too close yet. If it just set the wrong fuse bits, then maybe I just need to provide an external clock from the prop, and set the fuse bits again... not sure...

    It's hard to find the protocol going from avrdude to the programmer. The AVR910 docs seem to only give the programmer to avr protocol... so I'm a bit lost. I've been using the avr910.c portion of the avrdude sources to figure out bits and pieces... but it's tedious.

    Anyone else using this, or know anything that may help?
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-08-11 07:48
    I have "killed" a few smaller AVRs by getting the fuses wrong. They seem determined to "confuse the stupid" by having fuse set when low etc etc .. Confused me, but then I'm ...

    Usually the only way to resusitate them is the high volts programming method and not the ISP, as they are probably in the External clk or 32KHz mode. Couldn't be ***** to build one, chucked them, they're so cheap.

    Ponyprog and the fuse calculator are my favourates.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point

    Post Edited (Toby Seckshund) : 8/11/2009 8:11:04 AM GMT
  • heaterheater Posts: 3,370
    edited 2009-08-11 08:19
    I think that's why I ended up settling on the Propeller. My pile of "dead" AVRs was getting to big.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • DroneDrone Posts: 433
    edited 2009-08-11 08:55
    Ooooh, Propeller tames AVR - nice! I will have to play with this. By the way...
    Heater said...
    I think that's why I ended up settling on the Propeller. My pile of "dead" AVRs was getting too big.
    Get a $49 USD Atmel AVR Dragon from Mouser or Digi-Key. Dragon supports ISP/HVSP/JTAG/D-wire. Jumper the Dragon for HVSP, stick in your "dead" little AVRs, and bring them back to life in a matter of seconds using AVR Studio via FLIP (both free, see Atmel site). As a bonus, the Dragon also supports JTAG and D-Wire in-circuit debug for all parts with 32kB flash and less!

    Small AVR's are dirt cheap compared with the Propeller and with AVR Studio plus WinAVR you get a free un-crippled fully polished and supported IDE with debug, simulator, assembler, and GNU C/C++. That means you have double-precision floating point with AVRs (Yippee!)

    Not to say the Propeller doesn't have its merits too! I love the Propeller and use it all the time. They're really different parts for different jobs IMHO.

    I don't want to start a Propeller vs. AVR war. I just don't want to see anyone with a pile of "dead" AVR's in their junk box because of clobbered fuses or lock bits. They're likely not really dead =)

    Post Edited (Drone) : 8/11/2009 9:01:10 AM GMT
  • heaterheater Posts: 3,370
    edited 2009-08-11 10:59
    Drone: Interesting. I might get back to AVR one day if the need arises. Just now $49 + shipping is a lot to save a bunch of Atmega 8's and such. Plus I'd have to get into Windows for the IDE....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • trodosstrodoss Posts: 577
    edited 2009-08-11 15:34
    James Newman said...
    I've been working on this code, and getting started with AVRs for some USB stuff. Anyway, I tried to program the fuse bits of my ATTINY2313 to use the 20Mhz crystal, and now I have 2 unusable AVRs.
    FYI, If you are planning on using something like AVR-CDC or (or HID), BradC has some exellent code posted here·(a Prop-only USB Solution): http://forums.parallax.com/showthread.php?p=675656

    Thanks Drone!· Looks like·I need to get a·Dragon.· I have "killed" a number of ATTiny45's that may not actually be dead [noparse];)[/noparse]



    ·
  • RevAaronRevAaron Posts: 30
    edited 2009-08-11 16:25
    I'm seeing this thread for the first time- kudos micahp!

    /me wonders if micahp = picogui's micah?

    I've often wondered why there isn't a board that will program MCUs from different companies considering that so many of the simple programmers you find online are simply a PIC or AVR with a program like the one posted. Wouldn't be hard to detect, communicate, or switch between (jumper) target modes.

    James: I've not used it yet, but I'd be happy to get a USBlyzer dump for you. Unfortunately, I don't have any AVR chips other than the one (and only) within my Arduino. If you feel like posting me a cheapo ATTiny I could send you the log. Or, if you're on Windows you could try out USBlyzer yourself- IIRC they have a free trial.

    My one thought about Prop vs AVR: Different controllers for different projects. You can get PICs for as little as $0.35, pretty capable PIC16FXXs for $0.50, or an Atmega attiny for $2. I'm happy to spend $1 for a controller to stick inside a friend's card to do some silly LED blinkenlights, but there's no way I'd stick a Propeller in there. Not unless it was a Protoboard that happened to be the actual gift. :P

    I'd never waste a $8 Propeller on a toss-away project. Heck, I wouldn't waste a $4 MCU on one. But there are still plenty of fun little projects needing a only a small controller at the helm. OK- I'm done.

    Post Edited (RevAaron) : 8/11/2009 4:56:36 PM GMT
  • James NewmanJames Newman Posts: 133
    edited 2009-08-11 17:19
    Well, I went ahead and generated a 5Mhz clock with the prop, and that gets one of the chips to work, so it's set to external clock... I swear I set it right... but whatever. The other is still dead, havn't had time to try different things with it yet. Waiting on some more chips from sparkfun, so worth messing with until then.

    I'm trying to do a USB gamepad HID device as cheap as I can. I wouldn't mind going with the prop(, but for some reason I've turned down the prop-usb in my head... not sure atm why....

    Ohh and there are such things as Universal Device Programmers that will program everything from EPROMs to FPGAs to Pics to AVRs etc.... I saw one with 20000 supported devices.... only $700 [noparse];)[/noparse]

    Post Edited (James Newman) : 8/11/2009 5:38:59 PM GMT
  • Agent420Agent420 Posts: 439
    edited 2009-08-11 17:42
    OT: I typically use an old homebuilt parallel port programmer [noparse][[/noparse]STK200 clone] and more recently a cheap $5 from Futurelec through the programming interface in Bascom AVR. It is has a great comprehensible and failsafe fuse programming interface.

    http://www.mcselec.com/index.php?option=com_content&task=view&id=14&Itemid=41

    The Bascom demo version does not expire, and it works with all the common programming hardware. I much prefer it to PonyPro and AvrDude. Never had a chip go bad from a fuse setting using that setup.
  • James NewmanJames Newman Posts: 133
    edited 2009-08-12 18:25
    Ohh, the main reason I'm going with the prop for programming the AVRs is because I don't have a serial or parallel port anymore. My first thought was actually to use the prop-plug strait to the AVR, but all of the software out there uses some of the handshaking pins for important stuffs.

    Well, I played around with it last night and it seems to be programming the fuses right. I'm still having problems though. I set the 2313s lfuse to 0xEF, and can't ever get it to run from crystal. I can generate a signal from the prop and reprogram it back to 0x64 and run the internal just fine. Finally, I figured maybe I'm setting the fuses to the wrong values... since I'm able to bring it back with an external clock... so I set lfuse to 0x00. Still no crystal, and now it required a really high clock from the prop, due to the divide by 8.

    Anyway, I had been questioning my capacitors on the crystal for a while... I wanted 20p, but I think I'm way off. The site I had been using for quick reference for values had my 472s as 20p... but after thinking about it, that's obviously wrong. So I'ma find some 20p caps and see if that works.
  • Agent420Agent420 Posts: 439
    edited 2009-08-12 18:42
    I do many of my projects on breadboard, and the plastic brick material can cause parasitic capacitance issues with crystals causing the oscillation to fail.· The cheaper the breadboard, the more likely this will be an issue.

    Now I exclusively use TTL crystal oscillators as opposed to discrete crystals...· they're available in std through hole DIP package and are only $1 - $2.· The benefit is they are full clock circuts, so you apply vcc and get a no hassle clock signal out that feeds the avr external clock pin, no fussy capactiors required.· In fact, if ever a fuse was improperly programmed, these oscillators function as a clock so you can still communicate.

    edit - Example datasheet:
    http://www.ecsxtal.com/store/pdf/ecs_100.pdf






    Post Edited (Agent420) : 8/12/2009 6:51:01 PM GMT
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2009-08-12 19:23
    I added an external Osc block to my serial programmer to talk to the chips in ext mode (32KHz still mutes them). I tries the USB route (Ladyadda sort) worked ok but the drivers just didn't go in nicely, Leon says thay it's only good for XP anyway. We have old laptops mothballed at work so that we will get access to real serial ports for the older AMX and Crestron stuff. Our Sony's LANC sofware is only really happy on W98 and real (h378) parallel.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point
  • Agent420Agent420 Posts: 439
    edited 2009-08-12 19:42
    ^ OT - not sure of your specific issues, but we have some legacy W98 PLC software that uses the lpt port for communication.· After several unsuccessful attempts to get it working on various XP machines, I tried the free Virtual PC app available from Microsoft and installed a virtual W98 system on my XP hardware (you still need installation discs and serial # for whatever os you want to install).· I'll be damned if it doesn't work 100% without issue.· I'm sure some of this stuff may be software specific, but as VPC is a free download you might consider it.

    http://www.microsoft.com/windows/virtual-pc/download.aspx
  • James NewmanJames Newman Posts: 133
    edited 2009-08-12 22:51
    Ok, update. I got ahold of some 18p caps, and now I can get my 20Mhz crystal to work. [noparse]:D[/noparse] One of them is still dead, I may have really killed it though, as I was getting agitated and started messing with the high fuse on it. I don't remember what the last thing I did on it was, but I may have written to the disable reset or serial programming fuses. Anyway, got more on the way, and one working here... so tossing it.

    So... ummm the universal command works, and fuses write just fine. tongue.gif
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2011-05-12 13:24
    Having looked in AVRDude.conf, I can not find the ATMega164P at all. What is the code for the ATMega164P?????
  • SRLMSRLM Posts: 5,045
    edited 2011-05-13 01:32
    m164p

    123456
  • Igor_RastIgor_Rast Posts: 357
    edited 2014-11-25 20:29
    I was wondering if someone can help me make the changes in the program to get it to burn the bootloader in an Atmega1284

    All help apriciated
    THanks

    Igor
Sign In or Register to comment.