Help with reading 6MHz Parallel Bus - New to Teensy

lunallian

New member
Hello!

In my spare time, I've been working on building a Nintendo DS capture card from scratch. At the moment, I'm moreso just trying to make a proof-of-concept for the top screen video. For some background, the nintendo DS lite's top screen has 45 pins and is clocked at around 5.59MHz. However, only about half of those pins are relevant for what I'm currently trying to do: 18 pins for 6-bit colour, 1 dot-clock pin (the aforementioned 5.59MHz), 1 line-start pin, and 1 frame start pin.

I designed a custom breakout board for the top screen's connector cable, and put together a basic system with a raspberry pi Pico 2. The Pico 2 was good for prototyping, but is ultimately too slow to keep up with the amount of data (bottlenecked by the USB port). I got a teensy 4.1 to give me some more room to work with, and a higher speed USB port. However, the teensy 4.1 is by far the most complex microcontroller I've worked on and I am feeling quite overwhelmed trying to gather the information I need to start working with it.

TL;DR, I need to be able to read 21 pins in parallel, do a bit of data processing, and output through the USB port. What is the most effective way to accomplish this with the teensy 4.1? Which peripherals should I look into, and any suggestions as to resources to help me get a handle on the MCU?

Thanks :)
 
Take a look at the FlexIO library

You can use it to emulate a parallel bus or something similar to it.
Trigger a read of the shifter buffers on each clock pulse and copy to a large frame buffer that eventually gets sent on the USB bus

The T4.1 has just enough pins available on FlexIO3 to support your needs - but they are not DMA capable
 
I've done something similar with my Weapon Keyboard which uses a Teensy 4.1 as its controller. I set it up to read multiple keys simultaneously through a GPIO port register rather than calling digitalRead() over and over for each pin.

The Teensy 4.1 has 32-bit GPIO registers. In particular, GPIO6 has 20 accessible pins (0, 1, 14–27, and 38–41), which can all be sampled in one read using GPIO6_PSR.

For 21 inputs, you could put 20 on GPIO6 and the remaining input on another port, then read both registers in succession:
Code:
uint32_t sample1 = GPIO6_PSR;
uint32_t sample2 = GPIO7_PSR;


You'd then mask/shift to rearrange the appropriate bits before processing or sending the data over USB.

This should be very efficient for moderate sampling rates. If you need continuous high-speed acquisition or precisely simultaneous sampling, I'd investigate FlexIO, DMA, or an external parallel latch. I'd also buffer samples in memory and transmit them over USB in batches rather than making USB transfers part of the timing-critical sampling loop.

Aside from that, a useful starting point is PJRC's cores/teensy4/core_pins.h, which shows the Arduino pin-to-GPIO-register mappings. The i.MX RT1060 reference manual covers the underlying GPIO hardware.
 
Back
Top