Interrupt after a number of pulses wit STM32H563RG #89085
Unanswered
SchlossiLukas
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 all,
I'm using an STM32H563RG from STM.
I was able to make the qdec on timer1 run and read pulses from an external encoder. Now I wanna generate an interrupt after let's say 100 pulses. That interrupt should toggle a led
I mean the timer has interrupts, but i don't know how to use them in Zephyr.
That is my timerconfig in the devicetree:
tim: &timers1 {
compatible = "st,stm32-timers";
reg = <0x40012c00 0x400>;
clocks = <&rcc STM32_CLOCK(APB2, 11U)>;
resets = <&rctl STM32_RESET(APB2, 11U)>;
interrupts = <44 0>;
interrupt-names = "cc";
st,prescaler = <0>;
status = "okay";
};
Code to read the pulses:
const struct device *const dev = DEVICE_DT_GET(DT_ALIAS(qdec0));
const struct qdec_stm32_dev_cfg *dev_cfg = (const struct qdec_stm32_dev_cfg *)dev->config;
position = LL_TIM_GetCounter(dev_cfg->timer_inst);
printk("Number of pulses: %" PRIi32 "\n", position);
There is this interrupt API:
IRQ_CONNECT(MY_DEV_IRQ, MY_DEV_PRIO, my_isr, MY_ISR_ARG, MY_IRQ_FLAGS); irq_enable(MY_DEV_IRQ);
Pos 42 (prio 50) in the IR vector table of the µC is called "Update interrupt". Can I use this one? How can I define the number of pulses? Is that the ARR register? If yes, how can i change the value?
Thank you for you help.
Best regards
Lukas
Beta Was this translation helpful? Give feedback.
All reactions