mirror of
https://github.com/apache/nuttx.git
synced 2026-10-07 14:25:25 +00:00
arch/xtensa/src/common/espressif/esp_pcnt.c: counter accumulation fix
Port fix from risc-v code. Providing original description: Even when enabled, the PCNT counter doesn't accumulate into the 32-bit value. Instead, a value in range [PCNT_LOW_LIMIT, PCNT_HIGH_LIMIT] is always returned. This is due to interrupt events associated with limit overflows are disabled on the periphery, therefore the ISR responsible for the accumulation never gets called. Fixed by enabling the associated interrupt events. Signed-off-by: Martin Vajnar <martin.vajnar@gmail.com> Original-fix-by: michal matias <mich4l.matias@gmail.com>
This commit is contained in:
parent
6c1020204a
commit
907b487eb7
1 changed files with 5 additions and 1 deletions
|
|
@ -304,7 +304,7 @@ static int esp_pcnt_ioctl(struct cap_lowerhalf_s *dev, int cmd,
|
|||
ret = esp_pcnt_unit_get_count(dev, (int *)arg);
|
||||
if (ret != OK)
|
||||
{
|
||||
cperr("Could not clear pcnt-%d!\n", priv->unit_id);
|
||||
cperr("Could not get count from pcnt-%d!\n", priv->unit_id);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -894,6 +894,10 @@ struct cap_lowerhalf_s *esp_pcnt_new_unit(
|
|||
}
|
||||
|
||||
pcnt_ll_disable_all_events(ctx.dev, unit_id);
|
||||
|
||||
pcnt_ll_enable_high_limit_event(ctx.dev, unit_id, config->accum_count);
|
||||
pcnt_ll_enable_low_limit_event(ctx.dev, unit_id, config->accum_count);
|
||||
|
||||
pcnt_ll_enable_glitch_filter(ctx.dev, unit_id, false);
|
||||
pcnt_ll_set_high_limit_value(ctx.dev, unit_id, config->high_limit);
|
||||
pcnt_ll_set_low_limit_value(ctx.dev, unit_id, config->low_limit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue