esp32 wroom kit and zephyr timer1 counter #79115
Unanswered
GastonMelo
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi to all, Im new to zephyr and I tried to create a pwm output using timer1. In the overlay file I set the timer1 prescaler to 2 and status okay. With this presacaler setting I'm able to get 100Khz freq output, but why? Shouldn't be able to reach in the Mhz freq?
&timer1 { status = "okay"; compatible = "espressif,esp32-timer"; index = < 0x1 >; prescaler = <0>; };
in the main.c source I got this:
`
const struct device *timer1_dev =
DEVICE_DT_GET(DT_NODELABEL(timer1));
if(!device_is_ready(timer1_dev))
{
LOG_ERR("timer0 not ready");
return;
}
ret=counter_start(timer1_dev);
struct counter_alarm_cfg timer1_alarm_config = {
.callback = timer1_callback,
.ticks = 40,
.user_data = &timer1_alarm_config,
.flags = COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE,
};
ret = counter_set_channel_alarm(timer1_dev, 0, &timer1_alarm_config);
if(ret<0)
{
LOG_ERR("error starting timer0");
}
while(true)
{
k_sleep(K_FOREVER);
// gpio_pin_toggle_dt(&reset_pin);
// k_msleep(100);
}
return 0;
`
and in the callback function I got this:
`
int ret;
struct counter_alarm_cfg *config = user_data;
config->ticks = 40;
config->flags=COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE;
ret = gpio_pin_toggle_dt(&led);
ret = counter_set_channel_alarm(timer1_dev, 0,
user_data);
`
A couple of strange things happens:
2)the freq only reach 100Khz
is there a prescaler somewhere else that I need to set to be able to work with Mhz freq?
why the counter stops?
Thanks
Gaston
Beta Was this translation helpful? Give feedback.
All reactions