We often take our “SoftwareSerial” libraries for granted, and don’t investigate what goes on under the hood — until they fail us, at least. Would you like to learn how to harness the power of interrupt-driven bitbanging? [Jim Mack] teaches us how to make our protocol implementations fly using the LTC protocol as a springboard.
LTC (Linear/[Longitudinal] TimeCode) is a widely-used and beautifully-crafted protocol that tends to fly under our radar, and is one that hackers could learn plenty from. It’s used for synchronization of audio/video devices during media production and playback. LTC’s signal is almost digital but not quite: it doesn’t need a clock, and it has no polarity. Additionally, it mimics an audio signal really well, you can decode it at any playback speed, and many other benefits and quirks that [Jim] outlines. You do need to maintain the timings, though, and [Jim]’s article shows us how to keep them right while not inconveniencing your primary tasks.
Using interrupts means that your main loop gets to do other things, effectively letting you run different kinds of tasks in the background. [Jim] implements an LTC protocol transmitter using interrupts fired off at a defined frequency, doing LTC data processing in the main loop, and the time-critical GPIO wiggling from inside the interrupt handler code. He explains the code structure and the nuances along the way, and in the end, even provides us with source code of a highly capable and configurable LTC transmitter project for us to study and reuse. Be it RF transmitter bitbanging, IR remote signal reception, UART emulation, or any other protocols your MCU lacks peripherals for, this is where you learn to get it working.
In [Jim]’s previous article, he’s gone to great lengths explaining the fundamentals of precision and accuracy, then putting these theories into practice again, using an ATMega. In the next write-up of this series, he would like to create an LTC decoder, teaching us even more about properly using interrupts for timing-sensitive tasks. We can’t wait!