WARNING: callback 0 took 39ms

Hi,

After porting mbed OS on my board, when i try to printf a message using UART, and if the printf is in the app_start, i got this warning on my screen : WARNING: callback 0 took 39ms.
But if i try to use the printf in an other function in an other file i don’t get that warning message.

Can any one tell me the reason behind this warning?

Thank you.

I’m getting warnings like this too, playing around with the blinky example and adding an ADC read. I assumed it’s because too much time is being taken in an IRQ handler, as discussed here. So I scheduled a callback from the IRQ like so:

#include "mbed-drivers/mbed.h"
#include "minar/minar.h"
#include "core-util/FunctionPointer.h"

using namespace mbed::util;

AnalogIn ain(A0);
DigitalOut led(LED1);

static void blinky(void) {
    led = !led;
    printf("LED = %d \r\n",led.read());
}

static void howfar_output(void) {
    printf("ain: %g\r\n", ain.read());
}

static void howfar_irq(void) {
    minar::Scheduler::postCallback(FunctionPointer0<void>(&howfar_output).bind()).tolerance(minar::milliseconds(200));
}

void app_start(int, char**) {
    minar::Scheduler::postCallback(blinky).period(minar::milliseconds(1000));
    minar::Scheduler::postCallback(howfar_irq).period(minar::milliseconds(500));
}

I’m getting output that looks like this:

ain: 0.24591
WARNING: callback 0 took 14ms
                             ain: 0.247131
WARNING: callback 0 took 13ms
                             LED = 1 
ain: 0.239072
WARNING: callback 0 took 15ms

Any hints on how I fix this warning? I can make it go away by not using printf (just reading the ADC value into a float) but that’s not solving the broader problem of how to schedule non-trivial amounts of code without causing timing issues.

I’m using a NUCLEO-F401RE board, if that matters.

I got around to poking through the code and I guess the answer is just that since these callbacks (which are not interrupt handlers, as I initially guessed; duh, it says ‘scheduler’ right on the tin) are each run to completion before another scheduled task can begin, the goal is that you should write short, fast procedures so other tasks have a better chance of being run as close as possible to when you’ve scheduled them for.

So my options appear to be some combination of:

  • edit yotta_modules/minar/minar/minar.h and increase Warn_Duration_Milliseconds from its current value of 10,
  • make sure my functions run more quickly than Warn_Duration_Milliseconds, or
  • accept that there will be some warnings, other code execution might be deferred, and don’t sweat it.

I thought I should post this here because this thread is currently the only google result for “WARNING: callback 0 took”, and I imagine somebody else will have similar questions. Please do correct my understanding if I’m wrong, or add nuance I’ve missed.

On a related note, there doesn’t seem to be a lot of feedback on people’s questions about mbed OS here. Is there a better place to discuss it, or is it just that there’s not much assistance to be had? I assumed an open beta would have a bit more lively forum interaction.

Thank you for your post, it gave a proper way to take off those warnings than my way, actually, it was annoying while testing my uart and other drivers, so i deleted the line that was writing those warnings, it didn’t affect my program, still running well, but your way, is better, i will try it.

I totally agree there isn’t much interaction in this forum, and there is no other place to discuss mbed OS 3.0.