Teensy 3.0 touch sensing implementation

Status
Not open for further replies.

wpunkts

Active member
Hi,
this is mainly a question for Paul, but maybe someone else can help me too.

After playing around testing the touch sensing capabilities on a Teensy 3.0, I thought it might be a useful learning exercise to try to understand how the touch sensing is implemented. So I did just that and started looking at various files and the chip's reference manual. I think I have it all worked out, except for one thing: If I read the manual correctly, the chip has 16 touch sensing channels that can be connected to any of the GPIO pins. But I can't figure out where that connection is made in the Teensy's code.

It's not really important, but not being able to figure it out kind of bothers me.

Thanks for any hints,
Wolfgang
 
Thanks Paul.

Am I assuming correctly that following portConfigRegister to pins_teensy.c will lead me in the right direction?
 
OK, now that I think I understand how it works, I believe I have found a small error.

Line 1381 in mk20dx128.h reads
Code:
#define TSI_SCANC_EXTCHRG(n) (((n) & 7) << 16)
Shouldn't this be
Code:
#define TSI_SCANC_EXTCHRG(n) (((n) & 15) << 16)
instead (since EXTCHRG is a 4-bit field)?

Also, I have a new question. According to section 10.3.1 of the chip's reference, pins have a default signal on them and alternative, selectable functionalities ALT0 to ALT7. These can be selected by setting the three MUX bits in a pin's PORTx_PCRn register. Now, here's where I get a little confused: the MUX field of the PORTx_PCRn register is described on page 214 of the chip's reference as follows:

000 Pin disabled (analog)
001 Alternative 1 (GPIO)
010 Alternative 2 (chip-specific)
011 Alternative 3 (chip-specific)
100 Alternative 4 (chip-specific)
101 Alternative 5 (chip-specific)
110 Alternative 6 (chip-specific)
111 Alternative 7 (chip-specific)​

Besides the fact that the wording is somewhat unfortunate (since 000 appears to select ALT0), I don't quite understand the difference between the default and ALT0. For most pins the default signal and the ALT0 functionality are the same, but not for all (for instance Teensy 3.0 pin 24, which is PORTA_PCR5). But reading the MUX bits from PORTA_PCR5 when it should be in its default state returns 000. Does that mean there is a difference between 000 being present in the MUX field after the chip has booted, and actively writing 000 to select ALT0?
 
Status
Not open for further replies.
Back
Top