Page 2 of 4

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 2:54 pm
by RTOSman

Code: Select all

static THD_FUNCTION(Thread1, arg) {
   timeT = ST2MS(chVTGetSystemTime());
    while (1)
    {      
       My_func();
       chThdSleepUntil(MS2ST(timeT) );
       timeT += ST2MS(9);
   }

}


la led clignote exactement chauque 1MS mais apres 3 minutes j'ai une un erreur de 0.40 Secondes .
c'est quoi le souci

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 3:14 pm
by tfAteba
ok, can you share all your chibios project?
Then I'm going to do some test on my side!

We can communicate on the irc if you want tonight to have a live discution. I'will be connected at 20H30.

Thanks,

Theo

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 3:15 pm
by tfAteba
You can also read this it can sove your problem:
http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:timing

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 3:36 pm
by RTOSman
Je peux pas car, car c'est un projet pro, dans un cadre de R&D :) ya des fichier.h et .cpp que j'ai pas l'autorisation de les publié
jusye une question, tu sais comment faire un chronomètre. je veux chronométrer ma boucle while ??

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 3:53 pm
by tfAteba
You have an exemple on how to make a real time tack on the demo directory. But for that you have to use for exemple ChibiOS_16.0.3
The demo is locate in ChibiOS_16.1.3\demos\AVR\RT-ARDUINOUNO

This demo blink the LED every second.

To mesure a time execution you can use 2 variables for exemple start, stop and the debuger to see the difference.

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 4:08 pm
by RTOSman
ok thanks :)
so could you give write me a program that start evey 10MS exactely.
thanks

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 4:15 pm
by tfAteba
Take a look at the exmple everything is done. ChibiOS_16.1.3\demos\AVR\RT-ARDUINOUNO/ in the main.c
You just need a little modification to reach your gaol.

Did you try this?

Code: Select all

static THD_FUNCTION(Thread1, arg) {
  (void)arg;
  chRegSetThreadName("Blinker");
  while (true) {
    palTogglePad(IOPORT2, PORTB_LED1);
    chThdSleepMilliseconds(10);
  }
}


cheers,

Theo.

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 4:56 pm
by RTOSman
i told you i will not use sleepmilli function, i want my thread execute evey 10 ms, so i have to use sleepuntil :)
if my functiin take some microsecondes and i use sleep after the time incremente :) so we have to avoid sleep
my probleme is that i could'nt eliminate the errors

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 5:36 pm
by tfAteba
If you want to remove errors over the time, you have then to use absolute deadlines rather than fixed intervals as in my previous code.

you have an exemple here: http://www.chibios.org/dokuwiki/doku.php?id=chibios:kb:timing

You will then have the above code:

Code: Select all

msg_t my_thread(void *param) {
 
  systime_t time = chVTGetSystemTimeX(); // T0
  while (true) {
    time += MS2ST(10);  // Next deadline
    do_something();
    chThdSleepUntil(time);
  }
}

That what you want to do ;) .

cheers,

Theo.

Re: chThdSleepUntil() ??

Posted: Tue Feb 09, 2016 5:44 pm
by RTOSman
yes i did this but i still got errors :)
after 3 minutes