# LPTMR interrupt not working

Question asked by vinod Karuvat on Nov 27, 2014
Latest reply on Mar 30, 2015 by vinod Karuvat

Hello Friends,

I am toggling a pin using the LPTMR. When there is a timeout of the LPTMR, it will be interrupted and thereby toggle a pin.

the code is as stated below

#include "derivative.h" /* include peripheral declarations */

void LPTimer_IRQ(void);

int main(void)

{

int count;

uint16_t countTemp = 0;

asm(" CPSIE i");

MCG_C1 |= 0x02;

SIM_SOPT1 = 0;

SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

PORTB_PCR3 |= 0x00000100;    // alternative pin mux selection //

GPIOB_PDDR |= 0x00000008;    // pin direction //

PORTB_PCR4 |= 0x00000100;    // alternative pin mux selection //

GPIOB_PDDR |= 0x00000010;    // pin direction //

NVIC_ICPR = 1 << (28);

NVIC_ISER = 1 << (28);

/* Reset LPTMR settings */

SIM_SOPT1 = 0;

SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

LPTMR0_CSR=0;

LPTMR0_CSR |= 0x00000040;

LPTMR0_CMR = 600;

GPIOB_PTOR |= (1 << 3);

GPIOB_PTOR |= (1 << 4);

GPIOB_PTOR |= (1 << 3);

GPIOB_PTOR |= (1 << 4);

/* Start the timer */

/* Wait for counter to reach compare value */

asm("nop");

while(1){

//         if((LPTMR0_CSR & 0x00000080) == 0x00000080){

//             LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

//             LPTMR0_CSR |= 0x00000080;

//             LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

//             GPIOB_PTOR |= (1 << 3);

//             GPIOB_PTOR |= (1 << 4);

//         }

}

}

void LPTimer_IRQHandler(void){

if((LPTMR0_CSR & 0x00000080) == 0x00000080){

LPTMR0_CSR |= 0x00000080;

GPIOB_PTOR |= (1 << 3);

GPIOB_PTOR |= (1 << 4);

}

//     LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

//     LPTMR0_CSR |= LPTMR_CSR_TCF_MASK;

//     GPIOB_PTOR |= (1 << 3);

//     GPIOB_PTOR |= (1 << 4);

//     LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

}

But it does not go to the ISR (interrupt service routine).

The timer is turning on as I checked it in the non interrupt way.

Can anyone assist me pls.

Vinod.
{"ft_lang_label":"__label__en","ft_lang_prob":0.5807168,"math_prob":0.9743612,"size":2575,"snap":"2019-35-2019-39","text_gpt3_token_len":816,"char_repetition_ratio":0.2563205,"word_repetition_ratio":0.20512821,"special_character_ratio":0.44815534,"punctuation_ratio":0.1826087,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9879503,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-09-16T10:41:34Z\",\"WARC-Record-ID\":\"<urn:uuid:164a7701-e19f-4673-8020-bd72dc6b766d>\",\"Content-Length\":\"127569\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1c9fa9d8-bbb6-4c04-b46f-202560e49bae>\",\"WARC-Concurrent-To\":\"<urn:uuid:f8cc63a9-7622-4b13-a389-e6ce4b6942e5>\",\"WARC-IP-Address\":\"104.96.234.141\",\"WARC-Target-URI\":\"https://community.nxp.com/thread/336091\",\"WARC-Payload-Digest\":\"sha1:CZGQB6NPX5KRSQ4AYNIXCGQ5RZEHKLHO\",\"WARC-Block-Digest\":\"sha1:F7N5FDNUBXYQXUE5SA2JDG7V73Z5EIWJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-39/CC-MAIN-2019-39_segments_1568514572517.50_warc_CC-MAIN-20190916100041-20190916122041-00380.warc.gz\"}"}