if(pin_select==LPTMR_ALT1) //PTA19
{
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK; //Turn on PORTA clock
PORTA_PCR19=PORT_PCR_MUX(0x6); //Use ALT6 on PTA19
}
else if(pin_select==LPTMR_ALT2) //PTC5
{
SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK; //Turn on PORTC clock
PORTC_PCR5=PORT_PCR_MUX(0x4); //Use ALT4 on PTC5
}
LPTMR0_PSR=LPTMR_PSR_PCS(0x01)|LPTMR_PSR_PBYP_MASK; //Use LDO but bypass glitch filter
LPTMR0_CMR=LPTMR_CMR_COMPARE(compare_value); //Set compare value
LPTMR0_CSR=LPTMR_CSR_TPS(pin_select) //Set LPT to use the pin selected
|LPTMR_CSR_TMS_MASK // put in pulse count mode
|LPTMR_CSR_TPP_MASK //on falling edge (default)
|~LPTMR_CSR_TFC_MASK //counter register is reset on overflow
|~LPTMR_CSR_TIE_MASK //interrupt is disabled
|LPTMR_CSR_TEN_MASK; //Turn on LPT