The big question is how did I do it? First, I made a new programmer entry to the avrdude.conf:
- Code: Select all
#CH340 based USB-Serial/TTL adapters.
id = "ch340";
desc = "ttl port banging, reset=txd sck=!rts mosi=!dtr miso=!cts (invert signals using 74ls04)";
type = serbb;
reset = 3;
sck = 7;
mosi = 4;
miso = 8;
If you notice the description, the inverted pins are *not* actually inverted on the configuration, this is because you need to invert it using a NOT Gate (TTL-Logic is inverted RS-232 remember? So I used a 74ls04 on mine). The reason why the inversion of the pins are done by hardware, and not by the config file, is because the pin-state of the 2 important programmer outputs (SCK and MOSI. RST can be manually set.) are HIGH by default. I also noticed that the signals are not giving a clean HIGH and LOW states while the programmer is reading the AVR (with the 74ls04 it somehow gives an honest HIGH and LOW states). Of course there are still drawbacks. Sometimes it takes a few tries to be able to read the AVR with this (maybe a driver issue?), it almost always returns a wrong device signature, but with the -F option, I was able to program and set the fuse-bits (I don't suggest setting fuse-bits using this) of the AVR even with the wrong signature. But I noticed that at 14400 baud, being able to read the AVR properly is about 40/60. So I suggest that you use 14400 baud when using this programmer.
What is this good for then? This is good for those one-time programming such as flashing a bootloader. Once you have a bootloader in your AVR, you can use thie CH340 as the UART for uploading your sketches ( Also try FBoot). Also, CH340 adapters are WAY cheaper than those PL2303 based adapters.
I really hope this would help others, as I have not seen programmers that use the CH340 based USB-Serial adapters.