Work in Progress: uc-basics Workshop - Larson Scanner
A while ago fellow hacker dojoe asked me if I would like to join him to get a followup workshop to his very well received SMD soldering workshop going. He had the idea and plan to do a microcontroller basics workshop for a while now, but progress was stalled due to some unforeseen developments.
For a last weeks we were working on and off designing slides and content for the uc-basics workshop. Then over the previous weekend we started work on the sample solutions for the actual programming tasks.
There we ran into some - at first sight - weird behavior of interrupt driven multi-byte SPI transfers on the ATmega32U4. This called for some in depths research and experiments. The results of which I'll summarize in another post in the coming days.
The sample solution I was toying around with was an 74x595 shift-register driven LED Larson scanner. The final version will have two 74x595 in series for a total of 16 LEDs. Hence the requirement for sending two bytes and our trials of using interrupt driven transfers.
Turns out for a 2 byte case you get better performance sending the first byte, doing some calculations I had to do anyway, then actively wait for the transfer to finish to immediately start the second byte's transfer.
Once it worked I started optimizing till I hit the brick wall that is a combination of AVR interrupt latency and prologue/epilogue overhead (sneak-peak: a naked ISR that just toggles a pin on and off and doesn't do any prologue/epilogue still takes ~1 microsecond total execution time).
Once the brick wall was hit, I decided it's time to implement software PWM dimming. The result of which can be seen in the video above.