The official mbed C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Issue: Once detached, tickers can not be attached again

Once you have called ticker.detach() subsequent calls to ticker.attach() will not enable the ticker.

Platform: Nordic nRF51822

-Problem occurs with mbed library revision 89

-Problem does not occur with mbed library revision 88

sample code:

#include "mbed.h"

Serial serial(USBTX, USBRX);
Ticker ticker;

int toggle_flag = 1;

void measure() {
     printf("m\n");
}

void serial_in() {
    printf("%c\n", serial.getc()); 
    printf("toggle flag= %d\n", toggle_flag); 
    if (toggle_flag == 1) { 
        ticker.attach(&measure, 0.066666);
        toggle_flag = 0;
    } else {
        ticker.detach();
        toggle_flag = 1;
    } 
}

int main() {  
    serial.attach(&serial_in);
    
    while (1) {
        }
}

3 comments:

09 Oct 2014

Hi,

Is this related to this issue which was reported recently: https://github.com/mbedmicro/mbed/issues/539 ?

10 Oct 2014

http://developer.mbed.org/handbook/Ticker

Quote:

No printf, malloc, or new in ISR

In ISR you should avoid any call to bulky library functions. In particular, certain library functions (like printf, malloc and new) are non re-entrant and their behaviour could be corrupted when called from an ISR.

13 Oct 2014

Dmitry +1 for pointing it out, I did not check their ISR handler previously :-)

@Skot, if the issue is not related to the one I shared, please can you create a new issue on github mbed SDK repo? Thanks