- Don’t rely on the internal pull-up in the MCU for the nRESET pin. It might work for no-connect scenarios, but it’s not going to win a war against a Olimex programmer dongle that’s decided to lean on the pin a bit too hard.
- The linker needs to know what MCU it is too.
I basically found I had the ATTiny24A resetting repeatedly when the programmer was connected. Set a LED to stay on, it’d blink. The cause was the programmer was interacting with the MCU via the reset pin when connected. The solution was a resistor between 5V and reset, I stuck a 47k across the relevant pins of the ICSP header. (Annoyingly, they’re at opposite corners!)
The other blooper was having me scratching my head every time I tried to define an interrupt, the MCU would just sit there. Even if the ISR had nothing in it, and sei was never called, it’d still sit there dumb.
My Makefile at this point looked like this:
CFLAGS = -Os -g -mmcu=attiny24a -Wall -Werror CPPFLAGS = -DF_CPU=1000000UL CROSS_COMPILE ?= avr- CC = $(CROSS_COMPILE)gcc OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump SIZE = $(CROSS_COMPILE)size PROG_ARGS ?=-c stk500v2 -P /dev/ttyACM0 PROG_DEV ?= t24 .PHONY: clean all all: powerctl.ihex clean: -rm *.ihex *.elf *.o %.ihex: %.elf $(OBJCOPY) -j .text -j .data -O ihex $^ $@ %.elf: $(CC) -o $@ $^ $(SIZE) -d $@ $(OBJDUMP) -xdS $@ powerctl.elf: powerctl.o test.elf: test.o %.pgm: %.ihex avrdude $(PROG_ARGS) -p $(PROG_DEV) -U flash:w:$^:i
The call to objdump was to try and figure out what was going wrong. Note that I don’t pass -mmcu to the final link. The linker needs to know what MCU it is just as much as the compiler does. That was my error. Having done this, I now have working interrupts.







Recent Comments