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

My idea about ARTX isr_evt_set()

In the ARTX help say 'It might happen that two isr_evt_set() functions for the same task are called before the task gets a chance to run from os_evt_wait_xx() event waiting function. Of course one event is lost because event flags are not counting objects.' I think if two isr_evt_set() functions should be called, we can set the different bit of the event_flags, then no event will be lost. I mean the isr_evt_set() functions just OR the event_flags but not cover with the event_flags. My idea is right?

Parents
  • "I think if two isr_evt_set() functions should be called, we can set the different bit of the event_flags, then no event will be lost."

    But then it would be a different event now, wouldn't it?

    "I mean the isr_evt_set() functions just OR the event_flags..."

    ORs can't accumulate. ORing a 1 with a 1, resulting in a 1 does not make it more of a 1 now does it?

    "...but not cover with the event_flags"

    I don't understand what your are trying to ask with that last part.

Reply
  • "I think if two isr_evt_set() functions should be called, we can set the different bit of the event_flags, then no event will be lost."

    But then it would be a different event now, wouldn't it?

    "I mean the isr_evt_set() functions just OR the event_flags..."

    ORs can't accumulate. ORing a 1 with a 1, resulting in a 1 does not make it more of a 1 now does it?

    "...but not cover with the event_flags"

    I don't understand what your are trying to ask with that last part.

Children
  • Interrupts are in general not predictable. So you never know when an interrupt will happen. If you have a task which need to react on every event received from an interrupt function, then Kernel events are not a good means of doing this.

    This is because two (or more) interrupts might happen sequentially one after another before the task gets a chance to run. isr_evet_set() function just OR the event flags. Event flags are cleared when os_evt_wait_xx() function resumes it's execution. This is done by the Kernel itself.

    You should use semaphores instead. Each isr_sem_send() function call will increment number of tokens from a semaphore. In this way, no events are lost. Semaphore objects are counting objects comparing to Kernel event flags, which are not.

    Franc

  • Well, I give an example.
    void EXT3irq(void) __irq
    { isr_evt_set (0x0010, tskSendErrMSG);
    EXTINT = 0x00000008;
    VICVectAddr = 0x00000000;
    }

    void EXT2irq(void) __irq
    { isr_evt_set (0x0001, tskSendErrMSG);
    EXTINT = 0x00000004;
    VICVectAddr = 0x00000000;
    }

    void TaskSendErrMSG (void) __task
    { uint16 _retFlag;
    while (1)
    { os_evt_wait_or (0x0011, 0xFFFF);
    _retFlag = os_evt_get ();
    if (_retFlag&0x0001)
    {
    ...
    processA
    }
    if (_retFlag&0x0010)
    {
    ...
    processB
    }
    }
    }

    Of course EXT3 interrupt and EXT2 interrupt will not happer very frequently. When EXT2 interrupt happen, and the program not go to os_evt_wait_or, at this time EXT3 interrupt happen. So, in this condition, the event_flag will be cover as 0x0010? Or the event_flag is 'OR' as ox0011? processA will be lost? In another condition, EXT2 interrupt happen and the program just processing the task and still not finish, at this time EXt3 interrupt happen. In this condition, the event will be lost?

  • I think that with your example it might work. If both event flags are set before the task has resumed execution, it will resume execution only once. Howeveer both flags are captured and both events processed.

    This is a possible solution when it is guaranteed that one interrupt does not happen very frequently. For example when EXT2irq repeat again with no delay in between, one event will be lost.

    Franc