I'm trying to use the ATmega168-A chip in TQFP form, soldered onto a custom board allowing for programming via MISO/MOSI/SCK (to install the bootloader) and TX/RX (once the bootloader is installed). I'm looking to rely on the chip's internal clock, and have set up my fuses as such:
Low: 0xe2 (8MHz internal clock, not divided by 8 internally)
High: 0xdf (SPI enabled, no brownout detection)
Extended: 0x0 (1024-word bootloader section at 0x3800 bytes, with boot reset vector enabled)
Lock: 0x3f (no lock features enabled)
I compiled the Optiboot bootloader with the settings
atmega168: TARGET = atmega168
atmega168: MCU_TARGET = atmega168
atmega168: CFLAGS += '-DLED_START_FLASHES=0' '-DBAUD_RATE=115200'
atmega168: AVR_FREQ = 8000000L
atmega168: $(PROGRAM)_atmega168.hex
atmega168: $(PROGRAM)_atmega168.lst
This way, the bootloader was small enough to fit in memory without any problems. It does indeed fit fine on the chip, and running the command
sudo avrdude -c usbtiny -p m168 -e -B 1 -D -U flash:w:optiboot_atmega168.hex:i
indicates that the operation was successful. From everything I can tell, it's installed the bootloader correctly. However, when I try to run a similar command in order to install the sketch I'd like to run on the chip,
sudo avrdude -c usbtiny -p m168 -D -U flash:w:blink.cpp.hex
(Not necessarily the Blink sketch, but the end result is the same) it just doesn't even show any sign of life when it comes to uploading to the flash, staying at 0% for as long as I care to keep avrdude running:
Code: Select all
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9406
avrdude: reading input file "Blink.cpp.hex"
avrdude: writing flash (1108 bytes):
Writing | | 0% 0.00s
Later on, I set my fuse setting to 0xA2 (previous setting + clock output on PORTB0) and verified the chip does indeed output 8.33MHz from that pin, according to my scope, once you apply power & ground. (Goes to show you these internal clocks have a high tolerance range.) The chip must be alive as I can get the clock and can write to 0x3800, but I just can't write to 0x0000.
Any thoughts?
Thanks,
Stephen