New user - timer problems

Joel Sherrill <joel@OARcorp.com> joel.sherrill at OARcorp.com
Tue Feb 22 15:48:38 UTC 2005


Richardson, Anthony wrote:
> I think I am missing something fundamental with regard to
> the use of timers.  Calls to rtems_timer_create() and
> rtems_timer_initiate_server() return a status of
> RTEMS_NOT_CONFIGURED.  If I ignore the error returns
> everything seems to work ok, but I'm concerned I'm not
> configuring something that I should be.

You are probably using hello world as a starting point.
Look in the Makefile for

# optional managers required
MANAGERS=io

and change io to "all"


> A complete, simple test case is included below.  The
> 
> #define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
> 
> lines don't seem to help.  I threw them in when
> trying to get rid of the error.
> 
> I'm using RTEMS 4.6.2 on the PC.
> 
> Thanks,
> Tony Richardson
> 
> ===========================================================
> #include <bsp.h>
> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER
> #define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
> #define CONFIGURE_MAXIMUM_TASKS      3
> #define CONFIGURE_MAXIMUM_TIMERS     1
> #define CONFIGURE_MAXIMUM_SEMAPHORES 1
> #define CONFIGURE_INIT
> rtems_task Init(rtems_task_argument arg);
> #include <confdefs.h>
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> 
> rtems_id sem_id;
> rtems_id tim_id;
> 
> rtems_timer_service_routine my_timer(rtems_id timer, void *arg)
> {
>    // We just need to release the semaphore
>    rtems_semaphore_release(sem_id);
> }
> 
> rtems_task Init(rtems_task_argument ignored)
> {
>   rtems_status_code status;
> 
>   // Create semaphore, initially it should be unavailable
>   rtems_semaphore_create(
>      rtems_build_name('S','M','0','1'),
>      0,
>      RTEMS_SIMPLE_BINARY_SEMAPHORE,
>      0,
>      &sem_id);
> 
>   status = rtems_timer_create(
>      rtems_build_name('T','M','0','1'),
>      &tim_id);
>   // timer_create seems to always return an RTEMS_NOT_CONFIGURED error
>   // but works never-the-less.
>   printf("status = %d\n", status);
>   if (status != RTEMS_SUCCESSFUL && status != RTEMS_NOT_CONFIGURED) {
>      printf("Error creating timer 1\n");
>      exit(0);
>   }
> 
>   rtems_timer_initiate_server(
>      RTEMS_TIMER_SERVER_DEFAULT_PRIORITY,
>      RTEMS_MINIMUM_STACK_SIZE,
>      RTEMS_DEFAULT_ATTRIBUTES);
>   printf("status = %d\n", status);
>   if (status != RTEMS_SUCCESSFUL && status != RTEMS_NOT_CONFIGURED) {
>      printf("Error creating timer 1\n");
>      exit(0);
>   }
> 
>   printf("Entering application loop ...\n");
>   while(1) {
>      printf("Hello world!\n");
>      // fire timer
>      rtems_timer_server_fire_after(
>         tim_id,
>         5000/rtems_configuration_get_milliseconds_per_tick(),
>         my_timer,
>         (void *)NULL);
>      // wait for the semaphore, it is released by the timer
>      rtems_semaphore_obtain(sem_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT); 
>   }
>   exit( 0 );
> }


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985




More information about the users mailing list