I'm looking for advice on using a Teensy 4.0 to generate NTSC composite video from a buffer. By attaching an R2R resistor ladder to pins 14-17, I'm currently able to generate an image 52px wide with 15 shades of gray. You can see my source code and some pictures here: https://github.com/hypothete/teensytv
I'm able to get 1us timing by reading elapsedMicros in a while loop, but that limits my horizontal resolution to 52px because each row drawn in NTSC holds 52us of image data (63.5us overall). My goal is to get 320px horizontal resolution. For that, I need to accomplish a few things:
Here's what I think I could use to accomplish these tasks, but I could use a gut check on my assumptions. I'm fairly new to MCU programming, so I'm still shaky on some of these concepts.
Am I on the right track here? Any suggestions for next steps?
Thanks,
Duncan
I'm able to get 1us timing by reading elapsedMicros in a while loop, but that limits my horizontal resolution to 52px because each row drawn in NTSC holds 52us of image data (63.5us overall). My goal is to get 320px horizontal resolution. For that, I need to accomplish a few things:
- Pack 320 values plus start/end pulses into a signal that lasts 63.5us for each horizontal line
- Output that signal to 4 pins as efficiently as possible, probably not using digitalWriteFast()
- Long term, I'd like to pass updates at >3.58MHz so I can color-encode pixels, but improving the resolution takes precedence
Here's what I think I could use to accomplish these tasks, but I could use a gut check on my assumptions. I'm fairly new to MCU programming, so I'm still shaky on some of these concepts.
- A DMA channel seems like the right tool to transfer data from my buffer to the various pins
- It looks like most people use PDB to trigger the DMA transfer for sub-microsecond timings
- The Teensy 4.0 does not have GPIO "ports" in the same way that older models do, so I need to use something else for my DMA destination if I want to write to multiple pins at once. It seems like this is one use of FlexIO, but the reference manual is kind of vague about it.
- The Teensy 4.0 also does not have a DAC, so I'll need to stick with the resistor ladder for now. I do own the Rev D Audio Shield, but I am not sure if it would be a better substitute.
Am I on the right track here? Any suggestions for next steps?
Thanks,
Duncan