-
Hi im trying to use the counter API with stm32_min_dev_blue board.
And this is the zephyr.dts file after the build
This is my prj.conf
This is my code
If i build this everything is fine.
What is the correct way to include a counter to a stm32 timer? I'm missing something in the overlay? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Ok, it worked, this is the solution #47033 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
I came a cross the same issue on a nucleo_g474re board with the timer to not started as expected with timer shell. I propose to check the timer enable flag if it actually got set. Thus never triggered an interrupt handler. shell gets stuck on both uart:~$ timer periodic COUNTER_2 1000
uart:~$ timer oneshot COUNTER_2 0 1000 with the debugger realized the timer got never enabled. maybe this the same in your case. manually writing a uart:~$ timer periodic COUNTER_2 1000
COUNTER_2: periodic timer triggered for 10 times I'm not sure if it is intended behavior to have the shell get stuck on k_sem_take with the semaphore never being set, as the timer_alarm_handler never gets called. From my understanding no shell command for counters actually enables them. From the snipped below you see the counter to be configured at /* set an alarm */
err = counter_set_channel_alarm(timer_dev, (uint8_t)channel, &alarm_cfg);
if (err != 0) {
shell_error(shctx, "%s:Failed to set channel alarm, err:%d", argv[ARGV_DEV], err);
return err;
}
k_sem_take(&timer_sem, K_FOREVER); # never gets passed until counter is acutally enabled
shell_info(shctx, "%s: Alarm triggered", argv[ARGV_DEV]);
return 0;
} my sources to reproduce that main.c #include <zephyr/kernel.h>
int main(void)
{
while (1) {
k_sleep(K_FOREVER);
}
return 0;
} proj.conf
nucleo_g474re.overlay &timers2 {
st,prescaler = <79>;
counter {
status = "okay";
label = "counter_2";
};
}; |
Beta Was this translation helpful? Give feedback.
Ok, it worked, this is the solution #47033 (reply in thread)