I need help programming an ATMEGA48A

Discussion in 'Modding and Hacking - Consoles and Electronics' started by Bearking, Oct 7, 2016.

  1. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    As the title says I need some help programming the ATMEGA48A as used in this mod:
    http://nfggames.com/forum2/index.php?topic=5744.0

    I've got all the boards assembled but I completely missed the part about you having to use an external programmer to flash the ATMEGA chip. I wish this would have been clearer in the guide... I thought it could all be handled through the USB :(

    I need a cheap method to program this using the 6-Pin ISP pinout on the board. USB connection is required, I really don't want to mess with COM or Parallel-ports (which my PC doesn't have) :)

    Not sure if alternatives are available, but I do own an Arduino Uno dev board, Raspberry Pi 2 and a Xilinx Platform Cable USB. But I'm not sure if any of these could be used for the job, instead of buying another programmer.

    Any help would be greatly appreciated :)
     
  2. retro

    retro Resigned from mod duty 15 March 2018

    Joined:
    Mar 13, 2004
    Messages:
    10,354
    Likes Received:
    823
    If you're not going to buy an EPROM programmer, pay someone to program a chip for you.

    @Bad_Ad84 actually lists a blank chip programming service in his sales thread.
     
  3. Unseen

    Unseen Spirited Member

    Joined:
    Sep 1, 2014
    Messages:
    126
    Likes Received:
    17
    There is a way to do it using an USB hub... Not really recommended though.

    Here is a description for programming an AVR using the Raspi's GPIO pins
     
  4. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    Thank you for your suggestions, but like I said, I need to program this using the ISP pins on the board :)

    IMG_0209.JPG

    EDIT: Unseen, completely missed your second suggestion. Will take a look at that. Thank you :)
     
  5. Bad_Ad84

    Bad_Ad84 The Tick

    Joined:
    May 26, 2011
    Messages:
    8,613
    Likes Received:
    1,383
    You can program a flashing sketch to the arduino too IIRC.

    Or you can just buy one of the many cheap USB flashers - they are literally all over ebay for like £2
     
  6. rso

    rso Gone. See y'all elsewhere, maybe.

    Joined:
    Mar 26, 2010
    Messages:
    2,197
    Likes Received:
    455
    Sorry to be the bearer of bad news, but the hardware you need is really friggin expensive. Better put a second mortgage on the dog.
     
  7. Bad_Ad84

    Bad_Ad84 The Tick

    Joined:
    May 26, 2011
    Messages:
    8,613
    Likes Received:
    1,383
    retro likes this.
  8. Mord.Fustang

    Mord.Fustang Fiery Member

    Joined:
    Feb 17, 2013
    Messages:
    821
    Likes Received:
    185
    I haven't had that issue with my 2 USBasp's. They worked out of the box. Probably depends on source/batch??
     
  9. Marmotta

    Marmotta Dauntless Member

    Joined:
    Apr 14, 2009
    Messages:
    755
    Likes Received:
    49
    That guide for programming using a Pi seems pretty long-winded - if I were you I'd just buy Adafruit's USBtinyISP programmer or you can get a cheap one from China. I'd recommend AVRDUDESS for programming it; it's a straightforward GUI.
     
  10. Bad_Ad84

    Bad_Ad84 The Tick

    Joined:
    May 26, 2011
    Messages:
    8,613
    Likes Received:
    1,383
    Maybe. But if you don't have any other means to update it, not worth the risk over $1-2 that you still wont be able to use it.

    Once you have a working programmer, updating the usbasp is just plugging them into each other
     
  11. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,364
    Likes Received:
    783
    Since you already have an Arduino, that would seem the simplest approach. Just load up the "ArduinoISP" sample and program it to the board then use adrdude with -c avrisp -P <COM port it's connected to>
     
  12. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    I should say that I have barely had time to play with the Arduino Uno starter kit I got. I have hooked it up, managed to get a light flashing at various speeds and that's about that :D

    That being said I think I'll try this approach first, since having to install Raspbian on the Pi will take some time in itself.

    If I undersand correctly I just need to copy the ArduinoISP, which as far as I can see is already in the Arduino-software. And then connect it to a Windows PC and run the adrdude-program, which I should then point to the file I want flashed to the ATMEGA?

    Not entirely sure how to check which COM port is being used, as I'm really rusty in Windows, but I assume the hardware information in Windows can tell me this, when I've got the flashed Arduino connected by USB?
     
  13. Bad_Ad84

    Bad_Ad84 The Tick

    Joined:
    May 26, 2011
    Messages:
    8,613
    Likes Received:
    1,383
    yes to all of that
     
  14. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    I get the following error. Perhaps someone can help me figure out what is wrong.

    Code:
    C:\Users\Konsolkongen\Desktop\CDCE9XX_PROGRAMMER_FW_v1>avrdude -c avrisp -p m48 -P COM5 -U flash:w:CDCE9XX_PROGRAMMER_FW_v1.hex
    avrdude: stk500_getsync(): not in sync: resp=0xe0
    I've got the ISP pins of the target device hooked up to the ICSP pins of the Arduino. I've connected the 3 LEDs to pins 7, 8 and 9.
    I don't know if it's necessary but I've wired Reset from the ISP pins on the target device to pin 10 on the Arduino, as this apparently isn't connected on the ICSP pins.

    When I try flashing the error light immediately turns red. The COM port is correct according to the Device Manager.
    I'm probably doing something stupid :)
     
  15. TriMesh

    TriMesh Site Supporter 2013-2017

    Joined:
    Jul 3, 2008
    Messages:
    2,364
    Likes Received:
    783
    That all looks correct - and the connection to the reset pin is necessary.- try rechecking the connections between the Arduino and your target board.
     
  16. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    The connections are good. I've got two of these boards with the ATMEGA48, but none of them works.

    EDIT: Is the Arduino not able to power the target board using the ICSP pins?

    EDIT2: Tried using the offset pinheaders (pins 10-13) on the Arduino just to rule that out. Also powered the target board using it's USB input. But still getting the same error :(
     
    Last edited: Oct 9, 2016
  17. Nopileus

    Nopileus Rapidly Rising Member

    Joined:
    Mar 19, 2015
    Messages:
    77
    Likes Received:
    13
    Have you put a capacitor between reset and gnd on the arduino? (10uf or similar)

    I remember doing this once and running into loads of problems as well, said capacitor ended up helping. Keeps the uno from resetting itself at the wrong time.
    Regardless you should invest a few bucks in one of those cheap USBasp clones off ebay, works every time.
     
    Mord.Fustang likes this.
  18. sanni

    sanni Intrepid Member

    Joined:
    May 30, 2008
    Messages:
    653
    Likes Received:
    77
    I always use the Arduino as ISP programmer like this:
    Code:
    "C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe" -C "C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf" -c arduino -P COM5 -b 19200 -p m48 -U flash:w:"CDCE9XX_PROGRAMMER_FW_v1.hex"
    pause
    
    Just change the paths so they match your Arduino folder and copy paste everything into a flash.bat and be sure that you're using the right COM port. You can find it out using the Arduino IDE.
    Never needed any capacitors. Make sure you have an Arduino Uno following the original design. There are some clones with different usb serial chips, they might act differently.
     
  19. Bearking

    Bearking Konsolkongen

    Joined:
    Aug 2, 2010
    Messages:
    856
    Likes Received:
    100
    I have tried with the capacitor as well but that didn't help.

    Not sure I understand Sanni, what do you mean when you say flash.bat?

    The Arduino is an original.
     
  20. sanni

    sanni Intrepid Member

    Joined:
    May 30, 2008
    Messages:
    653
    Likes Received:
    77
    Open Notepad then:
    - Copy&paste the two lines into it
    - File->Save As...
    - File name: flash.bat
    - Save as type: All Files (*.*)
    You can save it to the desktop and then just double click on it.
     

Share This Page