AnsweredAssumed Answered

How can I configure the KL26 TPM as a free-running counter using the external clock input pin TPM_CLKIN0?

Question asked by Kyle Owen on Jan 24, 2017
Latest reply on Jan 28, 2017 by Mark Butcher

I'm using a Teensy LC with a KL26 and would like to eventually configure the two TPMs as free-running counters clocked by two separate clock inputs. Right now, I'm okay working on just getting one counter going. From reading the reference manual, this seems like it should be possible. Here's what I've configured so far:


SIM_SOPT4 = 0; //TPM0 uses TPM_CLKIN0 external clock pin

SIM_SCGC5 |= 0x00000400; //Port B clock gate enabled
SIM_SCGC6 |= 0x01000000; //Enable clock to TPM0
PORTB_PCR16 = 0x00000400; //Alt function 4, pulldown enabled

TPM0_SC = 0x00000010; //CMOD = 10 (TPM_EXTCLK increments count, no prescale)
TPM0_CNT = 0; //Reset counter


Despite the above configuration, I can never get TPM0_CNT to increment by toggling the TPM_CLKIN0 pin. I am able to configure the LPTMR unit as a free-running counter and have successfully used it by itself, but am in need of a second counter to run simultaneously. 


What else do I need to do to successfully use TPM0 as a free-running, externally-clocked counter? Thanks!