This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM RTOS help required urgent

hello friends
i have written the code for ARM RTOS, i have used same priority for all of my 4 task, its working fine

my problem is when i change the priority in the code then all task's are not executing simultaneously....
please any one help

Parents
  • here is my code

    #include<lpc214x.h>
    #include"adc.h"
    #include"buzzer.h"
    #include"spi.h"
    /* Include type and function declarations for RTX */

    #include <RTX_Config.h>
    #include <RTL.h> /* RTX kernel functions & defines */

    OS_TID tsk1; /* assigne identification for task 1 */
    OS_TID tsk2; /* assigne identification for task 2 */
    OS_TID tsk3; /* assigne identification for task 3 */
    OS_TID tsk4; /* assigne identification for task 4 */

    short counter1; /* counter for task 1 */
    short counter2; /* counter for task 2 */
    short counter3; /* counter for task 3 */
    short counter4; /* counter for task 4 */

    void job1 (void) __task;
    void job2 (void) __task;
    void job3 (void) __task;
    void job4 (void) __task;

    /*---------------------------------------------------------------------------- * Task 1: RTX Kernel starts this task with os_sys_init (job1) *---------------------------------------------------------------------------*/
    void job1 (void) __task
    { os_tsk_prio_self (2); /* higher priority to preempt job3 */ tsk1 = os_tsk_self (); /* get own task identification number */ tsk2 = os_tsk_create (job2,2); /* start task 2 */ tsk3 = os_tsk_create (job3,3); /* start task 3 */ tsk4 = os_tsk_create (job4,3); /* start task 4 */

    //while (1) /* endless loop */ { buzzer(); counter1++; /* increment counter 1 */ os_dly_wait (5); /* wait for timeout: 5 ticks */ }
    }

    /*---------------------------------------------------------------------------- * Task 2 'job2': RTX Kernel starts this task with os_tsk_create (job2,2) *---------------------------------------------------------------------------*/
    void job2 (void) __task /* higher priority to preempt job3 */
    { // while (1) /* endless loop */ { ADC(); counter2++; /* increment counter 2 */ os_dly_wait (10); /* wait for timeout: 10 ticks */ }
    }

    /*---------------------------------------------------------------------------- * Task 3 'job3': RTX Kernel starts this task with os_tsk_create (job3,1) *---------------------------------------------------------------------------*/
    void job3 (void) __task
    { // while (1) /* endless loop */ { SPI(); //counter3++; /* increment counter 3 */ //if (counter3 == 0) /* signal overflow of counter 3 */ //{ // os_evt_set (0x00ff,tsk4); /* to task 4 */ //os_tsk_pass (); //} }
    }

    /*---------------------------------------------------------------------------- * Task 4 'job4': RTX Kernel starts this task with os_tsk_create (job4,1) *---------------------------------------------------------------------------*/
    void job4 (void) __task
    { while (1) /* endless loop */ { //SCI(); //os_evt_wait_or (0x0001, 0xffff); /* wait for signal event */ //counter4++; /* process overflow from counter 3 */ }
    }

    /*---------------------------------------------------------------------------- * Main: Initialize and start RTX Kernel *---------------------------------------------------------------------------*/
    int main (void) { /* program execution starts here */ os_sys_init (job1); /* initialize and start task 1 */
    }

    /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/

Reply
  • here is my code

    #include<lpc214x.h>
    #include"adc.h"
    #include"buzzer.h"
    #include"spi.h"
    /* Include type and function declarations for RTX */

    #include <RTX_Config.h>
    #include <RTL.h> /* RTX kernel functions & defines */

    OS_TID tsk1; /* assigne identification for task 1 */
    OS_TID tsk2; /* assigne identification for task 2 */
    OS_TID tsk3; /* assigne identification for task 3 */
    OS_TID tsk4; /* assigne identification for task 4 */

    short counter1; /* counter for task 1 */
    short counter2; /* counter for task 2 */
    short counter3; /* counter for task 3 */
    short counter4; /* counter for task 4 */

    void job1 (void) __task;
    void job2 (void) __task;
    void job3 (void) __task;
    void job4 (void) __task;

    /*---------------------------------------------------------------------------- * Task 1: RTX Kernel starts this task with os_sys_init (job1) *---------------------------------------------------------------------------*/
    void job1 (void) __task
    { os_tsk_prio_self (2); /* higher priority to preempt job3 */ tsk1 = os_tsk_self (); /* get own task identification number */ tsk2 = os_tsk_create (job2,2); /* start task 2 */ tsk3 = os_tsk_create (job3,3); /* start task 3 */ tsk4 = os_tsk_create (job4,3); /* start task 4 */

    //while (1) /* endless loop */ { buzzer(); counter1++; /* increment counter 1 */ os_dly_wait (5); /* wait for timeout: 5 ticks */ }
    }

    /*---------------------------------------------------------------------------- * Task 2 'job2': RTX Kernel starts this task with os_tsk_create (job2,2) *---------------------------------------------------------------------------*/
    void job2 (void) __task /* higher priority to preempt job3 */
    { // while (1) /* endless loop */ { ADC(); counter2++; /* increment counter 2 */ os_dly_wait (10); /* wait for timeout: 10 ticks */ }
    }

    /*---------------------------------------------------------------------------- * Task 3 'job3': RTX Kernel starts this task with os_tsk_create (job3,1) *---------------------------------------------------------------------------*/
    void job3 (void) __task
    { // while (1) /* endless loop */ { SPI(); //counter3++; /* increment counter 3 */ //if (counter3 == 0) /* signal overflow of counter 3 */ //{ // os_evt_set (0x00ff,tsk4); /* to task 4 */ //os_tsk_pass (); //} }
    }

    /*---------------------------------------------------------------------------- * Task 4 'job4': RTX Kernel starts this task with os_tsk_create (job4,1) *---------------------------------------------------------------------------*/
    void job4 (void) __task
    { while (1) /* endless loop */ { //SCI(); //os_evt_wait_or (0x0001, 0xffff); /* wait for signal event */ //counter4++; /* process overflow from counter 3 */ }
    }

    /*---------------------------------------------------------------------------- * Main: Initialize and start RTX Kernel *---------------------------------------------------------------------------*/
    int main (void) { /* program execution starts here */ os_sys_init (job1); /* initialize and start task 1 */
    }

    /*---------------------------------------------------------------------------- * end of file *---------------------------------------------------------------------------*/

Children
  • And how do you expect anyone to be able to read that, when you didn't read the information on how to post source code?

    Repost the source code, but make sure it is properly tagged as code.

  • here is my updated working code, if i change the priority this code will not do all of the task
    can any one help for assigning other priority for this code to work for all task

    void job1 (void) __task
    {

    os_tsk_prio_self (2);
    tsk1 = os_tsk_self ();
    tsk2 = os_tsk_create (job2,2);
    tsk3 = os_tsk_create (job3,3);
    tsk4 = os_tsk_create (job4,3);
    buzzer();
    counter1++;
    os_dly_wait (5);
    }

    void job2 (void) __task
    {

    ADC();
    counter2++;
    os_dly_wait (10);
    }

    void job3 (void) __task
    {

    SPI();
    }

    void job4 (void) __task
    {

    SCI();
    }

    int main (void)
    {

    os_sys_init (job1);
    }