A problem when using printf in timer routine

PowerMan powerman1st at gmail.com
Tue Dec 16 11:16:09 UTC 2008


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.

My platform is s3c2410(arm920t), rtems-4.7.3, and the bsp is based on
gp32(s3c2400).
Because I made only a little change to the bsp of gp32,  I guess this bug is
not
my fault. Somebody please help me.

I know the rtems-4.9.1 had support smdk2410, but my board have
a lot of differences with it.

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.

#include <bsp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rtems/bspIo.h>

static rtems_id timer_id;
static rtems_name timer_name;
static const char timer_name_s[8] = "tmr0";

static rtems_timer_service_routine timer_show(rtems_id tid, void *pdat)
{
    printk("aa");
    printf("bb");
    printk("cc");
}

static int init_timer(void)
{
    /* build object name for timer */
    timer_name = rtems_build_name(timer_name_s[0], timer_name_s[1],
        timer_name_s[2], timer_name_s[3]);

    /* create timer */
    if (rtems_timer_create(timer_name, &timer_id) != RTEMS_SUCCESSFUL) {
        fprintf(stderr, "failed to create timer\n");
        return 0;
    }

    /* fire after 5 seconds */
    rtems_timer_fire_after(timer_id, 500, timer_show, NULL);

    return 1;
}

rtems_task Init(rtems_task_argument argument)
{
    if (!init_timer()) {
        fprintf(stderr, "failed to init timer\n");
        exit(0);
    }

    for (;;);

    if (rtems_task_delete(RTEMS_SELF) != RTEMS_SUCCESSFUL) {
        fprintf(stderr, "failed to delete init-task\n");
        exit(0);
    }
}

/**************** START OF CONFIGURATION INFORMATION ****************/

#define CONFIGURE_INIT

#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER

#define CONFIGURE_MAXIMUM_TASKS 10
#define CONFIGURE_MAXIMUM_TIMERS 10

#define CONFIGURE_TICKS_PER_TIMESLICE 10

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#include <rtems/confdefs.h>

/****************  END OF CONFIGURATION INFORMATION  ****************/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20081216/ad30ea5d/attachment.html>


More information about the users mailing list