A frustrating puzzle.
The following code works. It doesn't use the periodic measurement mode, but it accomplishes the same effect in the same number of instructions.
-- rec --
Code:
void tsi0_isr()
{
# toggle the led
GPIOC_PTOR |= (1 << 5);
# reset the end-of-scan flag, trigger next scan
TSI0_GENCS |= TSI_GENCS_EOSF | TSI_GENCS_SWTS;
}
TSI_GENCS_STM
void setup()
{
# configure the led as output
PORTC_PCR5 |= PORT_PCR_MUX(1);
GPIOC_PDDR |= (1 << 5);
# enable the tsi clock and the interrupt
SIM_SCGC5 |= SIM_SCGC5_TSI;
NVIC_ENABLE_IRQ(IRQ_TSI);
# reset the tsi module
TSI0_GENCS = 0;
# enable tsi_in 9 (pin 0 on the teensy board) as touch electrode
TSI0_PEN = (1 << 9);
# enable the general tsi interrupt, and the end-of-scan interrupt
TSI0_GENCS |= TSI_GENCS_TSIIE | TSI_GENCS_ESOR;
# enable the module, trigger scan
TSI0_GENCS |= TSI_GENCS_TSIEN | TSI_GENCS_SWTS;
}
void loop()
{
}