[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A problem when using printf in timer routine



On Tue, Dec 16, 2008 at 12:16, PowerMan <powerman1st at gmail.com> wrote:
> I used a app-timer in my program and encountered a problem, the service
> routine is
>
> static rtems_timer_service_routine timer_show(rtems_id tid, void *pdat)
> {
>       led1_on();
>       printf("%x\n", tid);
>       led2_on();
> }
>
> led1_on is ok, but the printf didn't return, so led2_on failed.
[snip]
>
> Somebody who have smdk2410 please try the following application and report
> the result to me. Thanks.
> On my board, "aa" is printed, but "bb" isn't.
>

As stated in the documentation:

"The Timer Server task is responsible for executing the timer service
routines associated with all task-based timers.
.....
However, since the Timer Server task is non-preemptible, only
directives allowed from an ISR can be called in the timer service
routine."

If I'm not wrong, printf needs to acquire a semaphore and you can not
do that inside a timer service routine, nor inside an ISR.

Aleix