9 years, 6 months ago.

Is there a better way to stop ticker?

Hello Everybody!

I am using the FRDMKL25z I have to attach and detach an timer interrupt. I am curently using the ticker class. I tryed to use the dettach and attach function, but it doenst work all the time.

I there a way to stop the timer that ticker uses?

Or disable timer interrupts? in this case, how do I know which timer ticker uses?

Also, How do I access registers in mbed if I want to?

Here is part of my code:

RATE is defined to 0.1s

void start(void){  
    
    t1.attach(&function, RATE);     
    
    }
    
void stop(void){   

    t1.detach();    
    
    }

Thanks !

1 Answer

9 years, 6 months ago.

It should work all the time. Detach is the way to go, and also automatically disables the timer interrupts if no more interrupts need to be set. It uses the LPTMR for the interrupts on the KL25.

Here are all register defintions for the KL25: https://developer.mbed.org/users/mbed_official/code/mbed-src/file/1f7ee966c9ea/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/MKL25Z4.h

You use them like:

LPTMR0->CSR |= LPTMR_CSR_TEN_MASK;

Quite soon you don't need that file anymore for most stuff, and you can figure out from the user manual which names to use :).

Accepted Answer