Programming an ATmega128, what way to go best? - Page 1
Forum section: electronics / general

author: Random Model Maker
author_rank: Regular Contributor
timestamp: July 10, 2018, 10:50:34 am
content: Hello beautiful people,I am currently at work (student intern) and I am trying to program an ATmega128, on a board, with an Arduino sketch. So far I have tried to program it with an Arduino ISP thing (this:https://store.arduino.cc/arduino-isp), but AVRdude always returns "invalid device signature".So the goal is to program the board with either the Arduino sketch or the exported Hex file via Atmel Studio 7.The board has both an ISP and JTAG port, with the following caveats:- To the PDI and PDO pins of the ISP also connects a MAX232 through 4.7kOhms resistors- I don't know if the JTAG is activated on the ATmega, as it has never been programmed before, it is "fresh out of the box".There are various methods to program this thing that I can find at my workplace:- A Segger J-Link Edu- A Segger Atmel SAM-ICE- Two Arduino UNO's- Said Arduino ISP- A selection of Altera and Xilinx programmers-BUTnobody seems to have a real ISP programmerTo the best of my knowledge, none of the programmers are actually compatible, I don't know if I can program the ATmega with the Arduino stuff via Atmel Studio 7, and through the Arduino IDE it doesn't seem to work.Would it maybe help to take out the resistors and disconnect the MAX232? That would definitely make testing the serial port rather tedious.It would not be dramatic if I had to buy an ISP programmer of some sort with company money, given that they do not cost a fortune, but it would mean I had to wait for another week until I can get going.

author: Random Model Maker
author_rank: Regular Contributor
timestamp: July 10, 2018, 12:50:31 pm
content: Hang on everybody, I have to backpedal a second.We have a genuine PEBCAK:I confused PDI and PDO on the PCB!Flipped the leads and sure enough. Miracle.Sorry for wasting your time everybody

author: ljwinkler
author_rank: Unknown
timestamp: July 10, 2018, 01:31:48 pm
content: The invalid device signature could be because you may be using a different version of the chip. I found these:ATmega128A 1e9702ATmega128RFA1 1ea701ATmega128 1e9702It's a common problem in the Arduino world, mixing the -P version with the non-P one.In the matter of programming... You can load Arduino bootloader and then just simply use the cheapest USB2Serial cable.You can find more details here:https://forum.arduino.cc/index.php?topic=134382.0or here:https://github.com/MCUdude/MegaCoreThere is a section describing contents of the boards.txt file where you define your board.I personally use AtmelStudio with VisualMicro add-in (https://www.visualmicro.com/). It adds Arduino's IDE functionality (libraries, boards, etc.) to AtmelStudio. There is also a debugging part. Some of the advanced functions are in the paid version (as of now the licence is $30 for 1PC).If you want an ISP - I use AVRdragon. It also supports high voltage programming for more stubborn (or 'bricked') MCUs. It comes very handy if you play with fuses and lock yourself outPlease note that loading program using ISP will overwrite the Arduino bootloader and you won't be able to use the USB2Serial to program it until you burn the bootloader again.The bootloader is simply a very small program that waits for the data coming over serial and the chip then programs itself in the memory range specified by the fusebits (it is after the bootloader reserved space).Or you can go fancy and use the Atmel's.... sorry, Microchip's ICE programmer.