Chronologist
Member
Greetings everyone,
for quite some time now I found myself at an impasse regarding the TSI module of the MK20DX256 (aka Teensy 3.2). I try to implement a simple continous capacitance measurement by utilizing the end-of-scan interrupt of the TSI module. However I can not seem to convince the MCU to execute the interrupt correctly. I also had a view into the NXP MCUXpresso SDK and could not find any special tricks that I might have missed. Therefore I turn to the community in hopes of enlightenment. I attach a minimal code example that in my opinion should be sufficient, since most parameters of the TSI module are fine in their default setting or just tune the measurement itself and not the functionality. I will be grateful for any possible insights.
Best regards,
Chrono.
for quite some time now I found myself at an impasse regarding the TSI module of the MK20DX256 (aka Teensy 3.2). I try to implement a simple continous capacitance measurement by utilizing the end-of-scan interrupt of the TSI module. However I can not seem to convince the MCU to execute the interrupt correctly. I also had a view into the NXP MCUXpresso SDK and could not find any special tricks that I might have missed. Therefore I turn to the community in hopes of enlightenment. I attach a minimal code example that in my opinion should be sufficient, since most parameters of the TSI module are fine in their default setting or just tune the measurement itself and not the functionality. I will be grateful for any possible insights.
Best regards,
Chrono.
Code:
void tsi0_isr()
{
# toggle the led
GPIOC_PTOR |= (1 << 5);
# reset the end-of-scan flag
TSI0_GENCS |= TSI_GENCS_EOSF;
}
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, the eond-of-scan interrupt and configure for periodic measurement
TSI0_GENCS |= TSI_GENCS_TSIIE | TSI_GENCS_ESOR | TSI_GENCS_STM;
# enable the module
TSI0_GENCS |= TSI_GENCS_TSIEN;
}
void loop()
{
}