diff options
-rw-r--r-- | demos/STM32/RT-STM32F746G-DISCOVERY/Makefile | 2 | ||||
-rw-r--r-- | demos/STM32/RT-STM32F746G-DISCOVERY/chconf.h | 2 | ||||
-rw-r--r-- | os/rt/include/chvt.h | 27 | ||||
-rw-r--r-- | os/rt/src/chvt.c | 7 |
4 files changed, 25 insertions, 13 deletions
diff --git a/demos/STM32/RT-STM32F746G-DISCOVERY/Makefile b/demos/STM32/RT-STM32F746G-DISCOVERY/Makefile index 40b040625..94853d1b3 100644 --- a/demos/STM32/RT-STM32F746G-DISCOVERY/Makefile +++ b/demos/STM32/RT-STM32F746G-DISCOVERY/Makefile @@ -5,7 +5,7 @@ # Compiler options here.
ifeq ($(USE_OPT),)
- USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
+ USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
endif
# C specific options here (added to USE_OPT).
diff --git a/demos/STM32/RT-STM32F746G-DISCOVERY/chconf.h b/demos/STM32/RT-STM32F746G-DISCOVERY/chconf.h index 1bda70597..206f1d11d 100644 --- a/demos/STM32/RT-STM32F746G-DISCOVERY/chconf.h +++ b/demos/STM32/RT-STM32F746G-DISCOVERY/chconf.h @@ -49,7 +49,7 @@ * @details Frequency of the system timer that drives the system ticks. This
* setting also defines the system tick time unit.
*/
-#define CH_CFG_ST_FREQUENCY 10000
+#define CH_CFG_ST_FREQUENCY 100000
/**
* @brief Time intervals data size.
diff --git a/os/rt/include/chvt.h b/os/rt/include/chvt.h index 3dc67f2a3..ea4493df3 100644 --- a/os/rt/include/chvt.h +++ b/os/rt/include/chvt.h @@ -395,19 +395,26 @@ static inline void chVTDoTickI(void) { systime_t now;
sysinterval_t delta;
- /* First timer to be processed.*/
+ /* Looping through timers.*/
vtp = ch.vtlist.next;
- now = chVTGetSystemTimeX();
-
- /* All timers within the time window are triggered and removed,
- note that the loop is stopped by the timers header having
- "ch.vtlist.vt_delta == (sysinterval_t)-1" which is greater than
- all deltas.*/
- while (vtp->delta <= chTimeDiffX(ch.vtlist.lasttime, now)) {
+ while (true) {
vtfunc_t fn;
+ /* The loop is stopped by the timers header having
+ "ch.vtlist.vt_delta == (sysinterval_t)-1" which
+ is greater than all deltas.*/
+ now = chVTGetSystemTimeX();
+ if (vtp->delta > chTimeDiffX(ch.vtlist.lasttime, now)) {
+ break;
+ }
+
+#if 0
/* The "last time" becomes this timer's expiration time.*/
ch.vtlist.lasttime = chTimeAddX(ch.vtlist.lasttime, vtp->delta);
+#else
+ /* The "last time" is set to the current time.*/
+ ch.vtlist.lasttime = now;
+#endif
vtp->next->prev = (virtual_timer_t *)&ch.vtlist;
ch.vtlist.next = vtp->next;
@@ -431,10 +438,8 @@ static inline void chVTDoTickI(void) { of the list.*/
chSysLockFromISR();
- /* Next element in the list, the current time could have advanced so
- recalculating the time window.*/
+ /* Next element in the list.*/
vtp = ch.vtlist.next;
- now = chVTGetSystemTimeX();
}
/* if the list is empty, nothing else to do.*/
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c index 1c5b2fea2..0667bf7c3 100644 --- a/os/rt/src/chvt.c +++ b/os/rt/src/chvt.c @@ -125,6 +125,13 @@ void chVTDoSetI(virtual_timer_t *vtp, sysinterval_t delay, vtp->prev = (virtual_timer_t *)&ch.vtlist;
vtp->delta = delay;
+#if CH_CFG_INTERVALS_SIZE > CH_CFG_ST_RESOLUTION
+ /* The delta could be too large for the physical timer to handle.*/
+ if (delay > (sysinterval_t)TIME_MAX_SYSTIME) {
+ delay = (sysinterval_t)TIME_MAX_SYSTIME;
+ }
+#endif
+
/* Being the first element in the list the alarm timer is started.*/
port_timer_start_alarm(chTimeAddX(ch.vtlist.lasttime, delay));
|