Tickless with lptim

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Tickless with lptim

Post by geoffrey.brown »

The stm32u375 can do dma io in stop
0 and stop1. To really exploit this I would need to keep tickless support active. Any advice on using an lptim to support tickless with lsi as the timer clock?

Geoffrey
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: Tickless with lptim

Post by geoffrey.brown »

after digging a bit deeper in history and the ChibiOS repo, it's clear there is no existing support for using an lptim as the tickless timing source. I'm guessing that the best way to proceed is a custom hal_st_lld with the following shape:
#define HAL_ST_USE_TIMER_WIDTH 16
#define ST_LLD_NUM_ALARMS 1
#define ST_LLD_HAS_PERIODIC_IRQ FALSE

#ifdef __cplusplus
extern "C" {
#endif
void st_lld_init(void);
bool st_lld_is_alarm_active(void);
systime_t st_lld_get_counter(void);
void st_lld_start_alarm(systime_t time);
void st_lld_stop_alarm(void);
#ifdef __cplusplus
}
#endif
if anyone has been down this path, please let me know.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Tickless with lptim

Post by Giovanni »

Hi,

LPTIMs are not supported mainly because their simple prescaler does not allow the generation of "round" frequencies, if this limitation is acceptable for you then you need to provide the functions you listed. You may create an alternate STv3 driver specific for LPTIMs if you don't want to mess with STv1 which is quite messy already.

Giovanni
geoffrey.brown
Posts: 122
Joined: Thu May 07, 2015 9:47 pm
Has thanked: 3 times
Been thanked: 18 times

Re: Tickless with lptim

Post by geoffrey.brown »

Thanks for your feedback. The real deal breaker turns out to be the timing of writing to LPTIM to set timeouts -- 2-3 LPTIM input clock ticks -- which would make millisecond waits a mess. Instead, I used application driven code in the idle loop

1) default is to use sleep
2) the application can choose STOPx at appropriate points such as
- starting a dma spi transfer
- waiting for an external interrupt

It's important that I only have a single thread and that the "appropriate points" are chosen to guarantee no timeout is pending. The stm32u375 preserves the timer state in STOP and keeps it running in sleep. So the only risk in stop is the timer loses time.

Here's a little snapshot of things running (some I/O lines elided).

1) wkup (yellow) -- the external interrupt signaling data availability
2) lsm_cs (orange) -- chip select on the sensor (an lsm6dsv)
3) flash clock (green) -- clock on the external (NOR) flash
4) low power (brown) -- sleep or stop active (signaled from idle loop)
5) stop mode (white) -- stop mode active (signaled from idle loop.
Logic Pro 8_2.png
Post Reply