How to program an ATmega328P, with a 3rd-party chip programmer, using the files generated by the Arduino IDE?

I've looked all over for a solution to this problem, but I'm stumped. Basically, here's what I want to do:

  1. write a program in the Arduino IDE
  2. convert it to a hex format that can be directly burned to an ATmega328P
  3. put that hex file into Xgpro (software that comes with the TL866II+/MiniPro) and burn it to my ATmega328P through a TL866II+ (aka MiniPro) Programmer
  4. have the blasted thing work for once, without having to program it in assembly

In case you don't know, use sketch → export compiled binary as an easy way to get the hex file. It creates a build directory (which contains the files) in the sketch directory

Do you have links (or documentation) for those 'things'?

I think I found it; is this the user manual? T56_TL866II USER GUIDE

yup, I was just about to send that exact link

here's XGecu's page for the product manuals and software: download software or data sheet about TL866 and ET7190

well, okay, not that exact link, but the official XGecu copy -- it's still the same file, though

When I try that, the chip doesn't do anything. I think it might need another step or a different type of compiling for the ATmega328P to understand it directly.

The problem can be the hardware that incorporates the 328P or your code. So please provide a full description of the project and the schematic where your 328P is incorporated; use a modified version (to match your hardware) of the blink sketch for testing purposes.

Your first problem might be the clock:

  1. For a design with an external 16MHz crystal you can select any of the above boards (for the Pro Mini you will have to select the correct clock frequency).
  2. For a design with an external 8MHZ crystal, you can select the Pro Mini and select the 8MHz option.
  3. If your design does not use an external 8MHz or 16MHz crystal, you will have to use the minicore board package (GitHub - MCUdude/MiniCore: Arduino hardware package for ATmega8, ATmega48, ATmega88, ATmega168, ATmega328 and ATmega328PB) and choose the correct setup.

As a result, your will get a hex file that matches the clock frequency.

Further you might have to set fuses; a new 328P has factory defaults which might not match your design.

  1. 4.10.1 in the linked user guide shows that you can read the fuses; I however don't see where the data is displayed. Only tick config and see what it tells you.
  2. 4.10.6 in the linked user guide seems to indicate that you can program the fuses.
1 Like

The circuit is the ATmega328P, with GND connected to 0V and VCC, AVCC, and AREF connected to 5V. On PB0 (Pin 14), there is the anode of an LED, with the cathode connected to 0V through a 220Ω resistor. The attached image shows the state of the fuses -- it is currently running off the internal 8MHz oscillator, with the CKDIV8 fuse not set. During programming, the chip is removed from the circuit and installed into the integrated ZIF socket of the TL866II+ and the HEX file is written directly to the ATmega328P.

EDIT: how do I add images?


There we go.

For reference, here's the process I go through to put the program onto the chip:

  1. Compile the program with the board set to Arduino Uno
  2. Put the HEX file into Xgpro (the one that's just "file_name.ino.hex" not the "file_name.ino.with_bootloader.hex", though it doesn't seem to make a difference which one I use)
  3. Set fuses for 8MHz internal RC oscillator, unset CKDIV8 fuse
  4. Program chip with ZIF interface, not ICSP interface

If I'm programming the chip directly with the HEX file, I don't think the clock frequency matters -- the program will just run half as fast (internal 8MHz RC osc as opposed to Arduino Uno's 16MHz crystal)

The clock frequency can matter; e.g. baud rates will be wrong. Hence the suggestion to use blink for testing purposes.

I'm not that familiar with fuse settings, maybe somebody else can help. I will however try to find time to have a look

The clock frequency of the chip wouldn't affect the programming process -- the TL866II+ synchronizes with the chip, and verifies that it passes the data correctly. The only thing frequency affects is execution speed, which wouldn't cause problems with blinking an LED, which is what my circuit does.

I know that :wink:

Decoupling capacitors?

There's a 0.1F supercapacitor across the power rails

And what does your sketch look like?
For the Uno Board Type, PB0 would be controlled via digitalWrite(8, ....) for example. Is that what you're doing?

Yes, the program is

void setup() {
  pinMode(PB0, OUTPUT);
}

void loop() {
  digitalWrite(PB0, LOW);
  delay(250);
  digitalWrite(PB0, HIGH);
  delay(250);
}

That doesn’t do what you think it does.
PB0 is a bit number (value: 0), not an arduino “PIN number”.

…oh.

Once I get home, I’ll try that and see if it works.

It works! Changing the pin number was the solution, but before it could work, I was probing around and realized that the GND on pin 22 didn't actually connect to ground. The one on pin 8 works, though, so I'm just connecting that instead.