Rate monotonic help

Matthews, Lee l.matthews at imperial.ac.uk
Mon Jul 25 17:44:14 UTC 2011


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20110725/02d89894/attachment.html>


More information about the users mailing list