Close

1K is not a lot of instructions

A project log for My Half Life Clock

A simple project using avr-libc and some cheap peripherals to implement a clock which counts down to a major life event.

mark-vandewetteringMark VandeWettering 12/22/2016 at 16:130 Comments

Okay, I know that 1K is not a lot of instructions. On the ATmega328, it's less 512 instructions. That's not a lot. But if you are coding in C, with the normal startup routines, you lose 26 double words right off the top for the interrupt table. I want to access an I2C squared device and also the TM1640. Peter Fleury's code to do the I2C part is actually pretty small, and the TM1640 isn't too bad, but by the time you have both of those in place, you likely have used somewhere north of 600 of your 1024 bytes. That means you have about 200 instructions left.

In that, you need to be able to implement all the rest of your logic. Bust apart the BCD numbers from the clock chip, compute days and time remaining, back to BCD and then out to the display.

I can do it all, but my almost-entirely feature complete version of the code runs about 1492 bytes at the moment.

I'm wavering in my conviction that it can be done, even in carefully handcrafted assembly code. I'm going to consult with one of my guru friends, and see what he thinks.

Discussions