#include "rtx51tny.h" #include "REG935.H"
const unsigned char table[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 ,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0xFF,0x00};
int counter0; int counter1; int counter2; int counter3;
void LED0 (void) _task_ 0 { int i; os_create_task(1); os_create_task(2); while(1) {
for (i = 0; i < 15; i++) {
P1 = table[i]; os_wait(K_TMO,30,0);
} os_send_signal(1); os_wait(K_SIG,0,0); counter0++; } }
void LED1 (void) _task_ 1 { int i; while(1) { os_wait(K_SIG,0,0);
for (i = 0; i < 3; i++) { P1 = table[15];
os_wait(K_TMO,30,0);
P1 = table[16];
os_wait(K_TMO,30,0); } os_send_signal(2);
counter1++; } }
void LED2 (void) _task_ 2 { int i; while(1) { os_wait(K_SIG,0,0);
for (i = 0; i < 8; i++) { P1 = table[i] | table[i+7]; os_wait(K_TMO,30,0); }
os_send_signal(0); counter2++; } }
Here is my programe, you can emulate it by the KEIL. Opening the "peripheral"-->"I/O port"-->"P1".you will see the movement of the P1.
Now I want to use the os_wait(K_IVL,0,0) instead of the os_wait(K_TMO,0,0) to see the differnce between them.But I can not see the difference.So who can help me to modify the programe to show the difference clearly.
Why starting a new task? http://www.keil.com/forum/docs/thread15625.asp
I afraid that no one replys me!
If you start new threads over and over you can be sure, that no one will reply...
Simply repeating the question won't help that!
In fact, if you just repeat the exact same question verbatim, it very much suggests that you haven't put in any more of your own effort - and that is likely to make people less likely to help.
If you don't get a reply, the best way to improve your chances is to give additional information and/or shown that you've given the matter some thought.
Remember, you are getting help for free - nobody is getting paid just to sit around waiting for questions, and then go away and look-up answers for you.
No one pay attention to my question sincerely.
You didn't pay attention to your question either. If you did, you would have posted the source code formatted as source code, and not just inlined with the text.
If you had payed attention, your code would have looked like:
#include <stdio.h> int main(void) { printf("Hello world!\n"); return 0; }
I don't have time to test your code, but I think the differences are well documented.
Timeout 5s means: the task waits for 5s Interval 5s means: the task executes every 5s independent of its execution time
Little example in pseudo code:
while (1) { wait(5s); // timeout or interval executeFunction(); // takes 2s to execute sendSignal(); // send a signal e.g. toggle LED }
If you use timeout, the signal will be send every 7s (5s wait + 2s execution). If you use interval, the signal will be send every 5s (3s wait and 2s execution).
thanks Stefan Hartwig and Per Westermark help! when the message have been posted,I can not edit it again even if I find the error.
Yes, that's true - that is why it is so important that you pay attention to the Preview before you post the message!
Now, you'll just have to re-post it: as a Reply in this thread - not as another new thread!
hi: Stefan Hartwig,I doubt your Little example
Because I make an experiment by following little programe:
while (1) { os_wait (K_IVL, 200, 0);//wait interval for 2s os_wait (K_TMO, 100, 0);//wait timeout for 1s os_send_signal (1); }
my result is that the signal will be send every 3s (2s wait for interval + 1s wait for timeout).The result is not that as my prediction:the signal will be send every 2s(1s wait for interval + 1s wait for timeout). the result is the same as following programe:
while (1) { os_wait (K_TMO, 200, 0);//wait timeout for 2s os_wait (K_TMO, 100, 0);//wait timeout for 1s os_send_signal (1); }
So , I still can not express the difference between tbem in programe.The reality is contrary to the theory .
It seems like you do not want to read the manuals: The Interval is a variation of the Timeout. An interval is like a timeout except that the specified number of clock ticks is relative to the last time the os_wait function was invoked by the task.
Maybe its a good idea to use interval and timeout in the same task...
By the way: In RL-ARM it is explicitly forbidden to intermix interval and delay/timeout wait functions.
hi: I have read manual about them. But I have not been comprehensible to this sentence: The Interval is a variation of the Timeout. An interval is like a timeout except that the specified number of clock ticks is relative to the last time the os_wait function was invoked by the task.
It means that the interval is a timeout in the normal state , but which state the interval will not behaved like timeout?
In your little programe, the interval didnot behave like timeout.
But in my programe ,the interval did behave like timeout.
your programe is in this condition:
except that the specified number of clock ticks is relative to the last time the os_wait function was invoked by the task.
isn't is?
why?
Result of using a periodic timer with value 5 ticks, and having code that takes 3 ticks to execute:
|xxx |xxx |xxx |
Result of using a delay with value 5 ticks, and having code that takes 3 ticks to execute:
Changing the delay to 2 ticks, would compensate:
But what happens if the code takes 1 to 3 ticks randomly, and you try to compensate with a 2 tick delay?
|x |xxx |xx |xxx |x |