cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder mode and interrupt on every edge

Rafal Skrzydelski
Associate II
Posted on July 10, 2017 at 15:58

Hello,

I have question about encoder mode. Can I use encoder mode for counting pulses and also generates interrupt on every counting pulse ? I need to set some variable on every encoder edge.

Regards

Rafal

4 REPLIES 4
Posted on July 10, 2017 at 17:13

Yes.

JW

Rafal Skrzydelski
Associate II
Posted on July 11, 2017 at 08:20

But which interrupt I should use ? I use STM32CubeMx for configuration encoder mode (TIM1) and in TIM1 configuration -> NVIC settings I see following interrupt:

- TIM1 break interrupt and TIM9 global interrupt

- TIM1 update interrupt and TIM10 global interrupt

- TIM1 trigger and communication interrupts and TIM11 global interrupt

- TIM1 capture compare interrupt

or maybe I should connect encoder parallel to encoder mode channels and do different pins with input capture ?

Regards

Rafal

Posted on July 11, 2017 at 08:47

Encoder mode is a feature of the slave-mode controller, ie. it controls the counter itself. This is independent from the capture process. In other words, you still can have enabled capture (and thus capture interrupt) on individual channels while counting in encoder mode.

Read the TIM chapter in RM, start with the timer's block diagram.

Whether it makes sense to do so, it's up to you - don't forget that you'll have an interrupt to handle upon every edge, whatever the input rate is, including bouncing on the edges if present.

JW

Posted on July 11, 2017 at 10:44

Thanks for your help, it's helpful

Regards

Rafal