Issues with Freescale KL25Z and Ticker/Timeout

03 Mar 2013

I posted this in Questions, but the Bugs & Suggestions forum is probably a better place.

The Ticker and Timeout functionalities don't seem to be working properly for small times (<70ms or so) on the KL25Z.

The ticker looks like it's either triggering multiple times per tick or skipping ticks.

Ticker example

#include "mbed.h"

DigitalOut out(PTA1);
Ticker tick;

void togglePin (void) {
    out = !out;
}

int main() {
    tick.attach_us(togglePin, 10000);
}

/media/uploads/stvnrhodes/img_20130301_155645.jpg

The timeout looks like it triggers in no faster than 65ms.

Timeout example

#include "mbed.h"

DigitalOut out(PTA1);
Timeout timer;

void toggleOff (void);

void toggleOn (void) {
    out = 1;
    timer.attach_us(toggleOff, 10000);
}

void toggleOff(void) {
    out = 0;
    timer.attach_us(toggleOn, 30000);
}

int main() {
    toggleOn();
}

/media/uploads/stvnrhodes/img_20130301_154615.jpg

It may be coincidence, but the cutoff seems to be close to 65535us, the maximum size of a 16-bit unsigned integer.

03 Mar 2013

Thank you Steven, this is a great report.

We will investigate this issue during the coming week.

Cheers, Emilio

05 Mar 2013

Hi Steven, we fixed the implementation of the "us_ticker_api" for the KL25Z. [mbed library revision 61]

Simply select the "mbed" library and click on the "Update" button in the right "Library Details" panel.

Thanks for reporting this issue.

Cheers, Emilio

14 Mar 2013

Hi all, I have the same problem, i use <<tick.attach_us(&time_impulse,130);>> for my dimmer program and i see same thing that ticker is not stable for my need. i try with <<wait_us>> in the main while loop and i have same resultas. I hope that will be a solution for this problem. Sorry for my poor english.

14 Mar 2013

Read the post before yours, there is a solution... Simply update your mbed library in your program and it should work.

14 Mar 2013

My mbed library is already updated to revision 61, but my wave form is not stable, after few minutes Thank you