Hi Roberto,

Try to sleep less than 1000us, because the sleep(X) means it will
sleep at least X us, not less, not equal.

BR,

Alan

On 3/9/22, Roberto Bucher <roberto.buc...@supsi.ch> wrote:
> Hi
>
> I've tried to modify the base timer from 10ms to 1ms, but in the
> execution of the generated RT Thread i get a overrun (of about 5ms...).
>
> I modified for this the "CONFIG_SCHED_TICKLESS" from 10000 to 1000.
>
> My board is a the STM32F746:nucleo-144 board. Are there other
> possibilities to get a shorter sampling time in my RT thread?
>
> The code for the sampling time is programmed as:
>
> -------------------------------------------------------------------------
>    while(!end){
>
>      /* periodic task */
>      T = calcdiff(t_current,T0);
>      NAME(MODEL,_isr)(T);
>
>      t_next.tv_sec = t_current.tv_sec + t_isr.tv_sec;
>      t_next.tv_nsec = t_current.tv_nsec + t_isr.tv_nsec;
>      tsnorm(&t_next);
>
>      /* Check if Overrun */
>      clock_gettime(CLOCK_MONOTONIC,&t_current);
>      if (t_current.tv_sec > t_next.tv_sec ||
>      (t_current.tv_sec == t_next.tv_sec && t_current.tv_nsec >
> t_next.tv_nsec)) {
>        int usec = (t_current.tv_sec - t_next.tv_sec) * 1000000 +
> (t_current.tv_nsec -
>                                   t_next.tv_nsec)/1000;
>        fprintf(stderr, "Base rate overrun by %d us\n", usec);
>        t_next= t_current;
>      }
>      clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &t_next, NULL);
>      t_current = t_next;
>    }
>
> ---------------------------------------------------------------------
>
> Thanks in advance
>
> Roberto
>
>

Reply via email to