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

RTX51-full - os_wait for ever

Hello all.
Can anyone help me with the following one?
My target is working under RTX51-full. I have an interrupt function (void mc12comm() interrupt 0 using 3) that calls other regular function, and this regular function creates a task. The task is enveloped with an endless loop (while 1) and at the end of the loop there's: os_wait(K_TMO, _2_SEC, 0);
I have about 5 tasks in the code and all of them works fine but in this task the program execute the os_wait function forever and not for 2 seconds as required.
Is it because the interrupt function calls regular function that creates a task?

Please help,
Reuven

Parents
  • Hello Reuven,

    Yes, your assumption is right. In the context of C51 interrupt functions calls to system functions named with the prefix 'os_' are not allowed. The complete code in the interrupt function, including all called functions, run under the context of the ISR.

    One solution is to create a fast or standard task and assign the interrupt with 'os_attach_interrupt'. In the tasks code, wait for the interrupt with 'os_wait'. The rest of the code can bee the same as you described.

    If you need the fast reaction of the ISR, create the task with the two seconds wait loop at configuration time. Use 'isr_send_signal' in the ISR to start this task.

    Hope this helps,
    Toni

Reply
  • Hello Reuven,

    Yes, your assumption is right. In the context of C51 interrupt functions calls to system functions named with the prefix 'os_' are not allowed. The complete code in the interrupt function, including all called functions, run under the context of the ISR.

    One solution is to create a fast or standard task and assign the interrupt with 'os_attach_interrupt'. In the tasks code, wait for the interrupt with 'os_wait'. The rest of the code can bee the same as you described.

    If you need the fast reaction of the ISR, create the task with the two seconds wait loop at configuration time. Use 'isr_send_signal' in the ISR to start this task.

    Hope this helps,
    Toni

Children
  • Thanks a lot Toni for your advices but nothing help.
    I will try to explaine againe my problem with a code sample:
    The init task creates TASK1 and enables interrupt 0. Interrupt 0 send a signal to TASK1. TASK1 waits for signal from interrupt function and when received it he clear the signal and creates other task - TASK2. TASK2 suppose to blink a LED. The problem is that when the program gets to the first wait statement he waits there forever!

    The question is WAY???

    For better understanding my current code looks something like that:

    void init() _task_ INIT
    {
    os_create_task(TASK1);
    os_enable_isr(0);
    }

    void int0() interrupt 0 using 3
    {
    os_send_signal(TASK1);
    }

    void task1() _task_ TASK1
    {
    while(1) {
    os_wait(K_SIG,255,0);
    os_clear_signal(TASK1);
    os_create_task(TASK2);
    }
    }

    void task2() _task_ TASK2
    {
    leds = on;
    os_wait(K_TMO, _2_SEC, 0);
    leds = off;
    os_wait(K_TMO, _2_SEC, 0);
    }

    P.S. I tried also:
    void task1() _task_ TASK1
    {
    If (os_attach_interrupt(0))
    os_delete_task(os_running_task_id());
    while (1) {
    os_wait(K_INT,0xFF,NULL);
    :
    }
    }
    but it also NOT helping me. The program, for some reason, doesn't attach the task to the interrupt and the task delete.

    PLEASE HELP :-((


  • void int0() interrupt 0 using 3
    {
    os_send_signal(TASK1);
    }


    Isn't there supposed to be isr_send_signal instead of os_send_signal ?

  • Thanks a lot Mike.
    You'r the man!!!

    (I must be more focused in what I'm doing...)