4.1: Max. number of digital ins with all analog ins in use

sascha

New member
Hello community,

I have some teensy boards for a long while, but new to this forum, so apologies in advance if my question had been answered somewhere a long ago. I'm presenting my project briefly, maybe it helps if there's no easy answer to the problem.

It's a long-term on-off project where I developed an e-drum trigger hardware & multi-layer sample player unit (aka 'drum brain' in drummers' terms). It consists of a 4.1 for the piezo trigger part (fed by a bunch of 6004 quad ops for signal conditioning and virtual ground), and configured as midi device. I use all available 18 analog inputs for piezo sensing as well as continuous control input for the hihat opening position. The teensy then does the necessary trigger detection dsp part (at a constant rate of 11kHz) and spits out midi note and cc (and is also configurable over midi). A Pi3 sitting in the same case (runing a sampler app in kiosk mode based on the JUCE framework) processes the midi data, and outputs 8 channels of audio at 44k1 using an Audioinjector Octo hat. A well-working solution so far that we use with the band for quite a while, although there's no edge or bell hit detection with cymbal pads at this point.

I have fiddled with the analog ins to also detect those membrane-switch presses, but it would mean I have to share inputs. I would like to use additional digital ins instead.

Considering I might still need 1 SPI channel and UART at some point, how many digital ins (i.e. gpios that can be converted into such) would I have left on the board? I'm not sure if I understand the specs correctly with regard to input/output configuration: can any gpio be configured to either state?
If I were to give up SPI & UART, would I be able to use those pins as additional digital ins?

Thanks,
Sascha
 
If the T_4.1 came with a CARD form PJRC look at that - or the online version if not.

All pins top and bottom - even the SDIO pins for the SD card can be used a Digital as they are marked in 'Gray'

So setting aside the needed pins for a UART and for SPI and taking the needed Analog Only pins in 'light Orange' with A# associated pins as A0 through A17 on the top side only then any remaining pin can be access as Digital with the number in 'Gray' shown closest to the PCB on top or bottom.
 
Thanks for explaining. I think it basically aligns with my understanding.
I've checked with one of the cards I still had around, and yes I'm using all the orange pins, but plenty of 'greys' around.

What I stumbled across was:
- 'Teensy 4.1 pins default to INPUT most with a "keeper" resistor.' -> For a non-native speaker like me, what is 'most', exactly? The default configuration on bootup?
- pin 5, 8, 38 are marked as IN (yellow), whereas 6, 7, 9 & 39 are marked as OUTPUT (also yellow). What are these yellow fields referring to?

Of course I can try pin-by-pin but just wanted to make sure I haven't missed an important part in the documentation.
 
Thanks for explaining. I think it basically aligns with my understanding.
I've checked with one of the cards I still had around, and yes I'm using all the orange pins, but plenty of 'greys' around.

What I stumbled across was:
- 'Teensy 4.1 pins default to INPUT most with a "keeper" resistor.' -> For a non-native speaker like me, what is 'most', exactly? The default configuration on bootup?
- pin 5, 8, 38 are marked as IN (yellow), whereas 6, 7, 9 & 39 are marked as OUTPUT (also yellow). What are these yellow fields referring to?

Of course I can try pin-by-pin but just wanted to make sure I haven't missed an important part in the documentation.

The T_4.1 card is Very Full and doesn't have a 'color guide' - but looking at the T_4.0 card the 'Yellow" is: "Digital Audio - Audio Library" - so like any other alternate purpose that coding only applies in those use cases.
As far as 'most with keeper' that isn't clear - I have not read that somehow - but assume some few pins related to startup or uploading cannot be held in state with 'keeper' resistors. Some of the bottom QSPI pins are activated on startup, and pins are activated in bootloader mode (#24 and #25) - it may be making reference to those - or some others - with that comment.
 
- pin 5, 8, 38 are marked as IN (yellow), whereas 6, 7, 9 & 39 are marked as OUTPUT (also yellow). What are these yellow fields referring to?

Yellow means Digital Audio. See the Teensy 4.0 card. Sadly, cramming the color info onto the Teensy 4.1 card just wasn't feasible without going to an unreadably small font size.

teensy40_card10a_rev2.png


The color code on Teensy 4.0 card also indicates which library or functions you would normally use to access the pin in that mode. For those yellow pins, if you use the audio library, the pin corresponding to which audio library features you use will switch from GPIO mode to controlled by the digital audio hardware. Likewise for the other colors. PWM in red, for example, means you can use analogWrite() which takes control of that pin.

Even if a library has taken control of a pin for a peripheral function, you can use pinMode() to put the pin back into GPIO control. Then you can use it with digitalWrite() or digitalRead(), but of course the peripheral no longer has access to that pin.

And if you *really* want to dive into the low-level register details, you can access the pin mux registers directly to control which peripheral has control over the pin. But that sort of thing is rarely done, because all the libraries do this for you. But those registers do give you access to some very fine detail control, like impedance of the pullup resistor or strength of the output drive. Most people just go with the default settings which work well in most situations, but if you want to play with those fine details, you can by accessing the low-level registers.
 
Back
Top