Close

Prototype for Firmware Development

A project log for Peppermint

A flag-themed blinky countdown memento for time spent apart, with capacitive touch switch.

benjamin-broceBenjamin Broce 10/07/2018 at 00:490 Comments

I plan on programming my boards using ArduinoISP from my Arduino UNO, so I thought I would get a jump-start on firmware development and testing an ISP setup by building a breadboard prototype of my circuit (as I've always programmed over UART in the past).

I soldered together a little SIP ISP programming header, and set the fuses of a DIP ATmega328P with Optiboot I had laying around to run with the 8MHz internal oscillator (since I didn't have a 16MHz crystal on hand, Nick Gammon's wonderful Arduino tools helped me out with an alternate clock source). On the actual board, I plan on using the 8MHz oscillator for the CPU, and running a Timer2 RTC with an external 32KHz crystal. After laying things out (including a button to simulate the touch sensor), a simple test program (blinking one of the Charlieplexed LEDs) worked great:


After some research into more easily controlling a Charlieplexed LED matrix, I went with Alexander Brevig's Charlieplex Library. This allowed me to run a more complex test with all of the LEDs, and had a great design for storing matrix pairs in an array of structs, but a bug quickly surfaced that could affect minimum refresh time on larger displays - If I didn't clear() the display before switching an LED on every time, then multiple LEDs were lit (which means that not all of the 6 control pins were truly driven into high-impendance "disconnect" upon writing a "low" using the library's charlieWrite() function). I modified the library to my liking, including the fix to this bug (writing both control pins for an LED to high-Z disconnect - input mode written LOW - upon writing the LED to "low" using the library).

Next was to figure out sleep modes and pin-change interrupt wakes via the touch sensor. Nick Gammon's tutorials were again extremely useful, and got me up and running with a writing registers for interrupt setup. I can't test anything I write for the Timer2 timekeeping interrupts until I assemble a prototype board, because I don't have a 32KHz crystal on hand, but that and ultra-low sleep modes are the next steps. I also would like to allow shorting of some of the ISP pins to 3V3 to allow for setting the "time" in case of power failure or reset...

Videos are taken, but not yet hosted anywhere - they'll come later.

Discussions