-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: kernel: timer_api fails with CONFIG_STM32_LPTIM_TIMER #20992
Conversation
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
7881a98
to
3c3c0f9
Compare
If the irq has not yet been handled but the counter just resets after the roll-over we must add thi roll-ove value in the actual counter position |
a4cce57
to
fa3afb0
Compare
Changed the calculation of the nb of hw cycles which is returned by the z_timer_cycle_get_32() function in case of LSE clock. Remaining work: set a timeout close to the current counter. |
97ec815
to
5f12eaa
Compare
This version passed kernel test on nulceo_l4r5zi board with LPTIM timer running on LSI clock |
44bac7b
to
79681dd
Compare
as nucleo_wb55rg board has CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000 |
1a82e0c
to
e62e5ff
Compare
on nucleo_wb55rg (lptim on LSI) : also passed with nucleo_l4r5zi with lptim sourced by LSI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Late to this one, sorry. I can't speak to the hardware obviously, but the timer logic all looks correct.
default 32000 if STM32_LPTIM_CLOCK_LSI | ||
default 32768 if STM32_LPTIM_CLOCK_LSE | ||
default 32000 if STM32_LPTIM_CLOCK_LSI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not useful but ok
@jdascenzio, are you fine with the last changes ? |
change after @erwango 's review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more tweaks and I'm good
@@ -340,7 +340,7 @@ | |||
}; | |||
|
|||
lptim1: timers@40007c00 { | |||
compatible = "st,stm32-timers"; | |||
compatible = "st,stm32-lptim"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you fix this on stm32wb as well ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Autoreload value must be decrement by one Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
When the tickless kernel isn't used, we don't want to wait for ARROK. This wait can be endless. Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
In the timeout function, remove the compilation flag and use the macro instead. Signed-off-by: Francois Ramu <francois.ramu@st.com>
The current value of the counter must not be added to the accumulator. It will be added when calling z_timer_cycle_get_32. Signed-off-by: Julien D'Ascenzio <julien.dascenzio@paratronic.fr>
set the min and max values of the given ticks from 0 to LPTIM_TIMEBASE which is the full register value In case the timeout is FOREVER, then lptimer is stopped Signed-off-by: Francois Ramu <francois.ramu@st.com>
This change makes the lptimer running with lower tick periods and small tick values Signed-off-by: Francois Ramu <francois.ramu@st.com>
based on PR#25412 Some kernel tests use `CONFIG_TICKLESS_KERNEL=n` with `CONFIG_SYS_CLOCK_TICKS_PER_SEC=1` to detect when a test runs longer than 1 second. These tests break if a tick is announced every time a timeout occurs. Only announce if the measured duration since the last tick is at least the duration of a tick. Signed-off-by: Francois Ramu <francois.ramu@st.com>
This is defining the SYS_CLOCK_TICKS_PER_SEC default value depending on the LPTIM CLOCK frequency in case of LPTIMER, to get a TICK value as a divider of the LPTIM clock source. It gives a better result in formulas when converting ticks to count unit. Signed-off-by: Francois Ramu <francois.ramu@st.com>
rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beside the minor nitpick, all looks good. I tested it on a Nucleo L432Kc board and I confirm the issue is fixed by this PR.
drivers/timer/Kconfig.stm32_lptim
Outdated
bool "STM32 Low Power Timer" | ||
depends on (SOC_SERIES_STM32L4X || SOC_SERIES_STM32WBX) | ||
bool "STM32 Low Power Timer [EXPERIMENTAL]" | ||
depends on SOC_SERIES_STM32L4X && DEVICE_POWER_MANAGEMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: I don't fully see the relation of why the LPTIM support needs to depend on DEVICE_POWER_MANAGEMENT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal is to link lptim to low power mode.
This let kernel timer unchanged for most of the usecase.
The lptim is able to preserve the kernel tick counter during low power sleep mode : only in this case is the lptim configured to keep the kernel timeout.
Refering to power: stm32l4: support of the Low Power Mode #19026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. In that case shouldn't it be SYS_POWER_MANAGEMENT
instead of DEVICE_POWER_MANAGEMENT
?
Another comment: when setting This seems to be a math issue in |
@erwango please re-review |
Adds a new LPTIM binding for stm32 soc, based on the timer binding. This will makes a specific filter on dt_compat_enabled("stm32,lptim") Signed-off-by: Francois Ramu <francois.ramu@st.com>
Activation of the LPTIMER is valid for SLEEP MODE only The choice of the lptim clock source is STM32_LPTIM_CLOCK set the LSE in first position to have as default value Signed-off-by: Francois Ramu <francois.ramu@st.com>
For nucleo_l4r5zi board, the LPTIM clock source is defined as LSE as default. Signed-off-by: Francois Ramu <francois.ramu@st.com>
include lptim in the stm32wbx series |
Testing kernel/timer/timer_API with LPTIM on stm32L4R5
the test_timer_duration_period fails w"
test_timer_duration_period: tdata.expire_cnt == 4 is false"
LPTIM_CLOCK % CONFIG_SYS_CLOCK_TICKS_PER_SEC
Activation of the LPTIM remains an experimental feature to generate kernel timings.
Fixes #20991