Rate monotonic help

Joel Sherrill joel.sherrill at OARcorp.com
Mon Jul 25 17:50:20 UTC 2011


What is your clock tick configured as?  This is the
CONFIGURE_MICROSECONDS_PER_TICK configuration
parameter.

FWIW your code assumes that 1 tick == 1/122 of
a second from what I can tell and that can't be
right.

--joel

On 07/25/2011 12:44 PM, Matthews, Lee wrote:
>
> Hi
>
> I’m developing some software that uses RTEMS on an Aeroflex Gaisler 
> LEON3 processor that is running on a Pender GR-CPCI-AX2000 development 
> board.
>
> I’d like to setup a task that is called 122 times per second. I’m 
> currently trying to use the rtems rate_monotonic functions but I’m not 
> having much luck.
>
> I have used the example code from the rtems_user_guide as a guide.
>
> My function looks like the following :
>
> rtems_task Periodic_task()
>
> {
>
>       rtems_name name;
>
>       rtems_id period;
>
>       rtems_status_code status;
>
>       unsigned int flag=0;
>
>       unsigned long count=0;
>
>       unsigned int i=0;
>
>       printf( "Starting periodic function : 61Hz clock output.\n");
>
>       printf( "Turning GPIO OFF.\n");
>
>       gpiolib_set(port1,1,0); // Set GPIO0 to OFF
>
>       for(count=0;count<1000000;count++) {}
>
>       printf( "Exiting wait loop.\n");
>
>       name = rtems_build_name( 'P', 'E', 'R', 'D' );
>
>       status = rtems_rate_monotonic_create( name, &period );
>
>       if ( status != RTEMS_SUCCESSFUL ) {
>
>             printf( "rtems_monotonic_create failed with status of 
> %d.\n", status );
>
>             exit( 1 );
>
>       }
>
>       while ( 1 ) // RTEMS ticks per second set to 122.
>
>       {
>
>             if ( rtems_rate_monotonic_period( period, 1 ) == 
> RTEMS_TIMEOUT )  break;
>
>             /* Perform some periodic actions */
>
>             if(flag==0)
>
>             {
>
>                   gpiolib_set(port1,1,1); // Set GPIO0 to ON
>
>                   flag=1;
>
>             }
>
>             else
>
>             {
>
>                   gpiolib_set(port1,1,0); // Set GPIO0 to OFF
>
>                   flag=0;
>
>             }
>
>       }
>
>       /* missed period so delete period and SELF */
>
>       status = rtems_rate_monotonic_delete( period );
>
>       if ( status != RTEMS_SUCCESSFUL ) {
>
>             printf( "rate_monotonic_delete failed with status of 
> %d.\n", status );
>
>             exit( 1 );
>
>       }
>
>       status = rtems_task_delete( RTEMS_SELF );
>
>       /* should not return */
>
>       printf( "rtems_task_delete returned with status of %d.\n", status );
>
>       exit(1);
>
> }
>
> I’d like for the function to turn one of the GPIO lines on and off 
> repeatedly, but all that seems to happen is that the code within the 
> while ( 1 ) loop executes once, then stops.
>
> The code that I use to create and start this task is the following :
>
> Task_name1 = rtems_build_name( 'P', 'E', 'R', 'D' ); // Set task name 
> to 'PERD'
>
>                 status = rtems_task_create(Task_name1, 1, 
> RTEMS_MINIMUM_STACK_SIZE * 2, 
> RTEMS_DEFAULT_MODES,RTEMS_DEFAULT_ATTRIBUTES, &Task_id1);
>
>                 if(status!=RTEMS_SUCCESSFUL)
>
>                 {
>
>                                 printf("rtems_task_create unsuccesful\n");
>
>                                 exit( 0 ); // Exit
>
>                 }
>
>                 else
>
>                                 printf("Created Periodic task\n");
>
>                 status = rtems_task_start( Task_id1, Periodic_task, 1 
> ); // Start Periodic task
>
>                 if(status!=RTEMS_SUCCESSFUL)
>
>                 {
>
>                                 printf("rtems_task_start unsuccesful\n");
>
>                                 exit( 0 ); // Exit
>
>                 }
>
> Could anyone shed some light on what I’m doing wrong please?
>
> Thanks in advance,
>
> Lee
>


-- 
Joel Sherrill, Ph.D.             Director of Research&  Development
joel.sherrill 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