Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

STM32 HAL - Encoder Interrupt

azadfalah

Full Member level 2
Joined
Aug 13, 2016
Messages
145
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
2,423
hi friends,

In STM32F412 microcontroller with HAL Library
I put timer 2 in encoder mode and everything works fine

I want, for example, if the counter reaches 1500, an interruption will occur, but I don't want the counter value to be reset after this interruption.
How can I do this?
I want the number 1500 to be recognized very quickly. When I check this value in the Super loop, every time the CPU may be involved in small delays (like LCD Update) and exceed the set value.


The things I did -> I thought it was possible to use timer 3 as a slave so that timer 3's clock is supplied from counter timer 2 But I was not successful



Thanks,
 
Hi,

I have no idea
* which encoder you are talking about
* which HAL function you are taking about
* what´s the counter is used for
* what the "interruption" is meant to do
....

Klaus
 
Hello!

Ideally, you should explain exactly what you want to do.
Usually a timer has a certain number of bits, you can count in either direction, and you can detect
a given value. And depending on your setting, it might reset or not if you have reached that value.
So what do you want to do
- Start from 0
- Issue an interrupt when counter interrupt when the value reaches 1500, but leave the counter going upwards.
At this point, will the interrupt still be enabled? Asking this because usually a timer can be configured one-shot
or recurrent.
- At this point, what do you want to do?
-> If you leave it like this, assuming it's recurrent, it will go to 65k if it's a 16 bit counter, or to 4+ G if it's a 64 bit. And it will detect
1500 again when it rolls over. Is this what you want?

As fir this:
I want the number 1500 to be recognized very quickly

An interrupt takes a number of cycles to be called, and this depends on your MCU. That must be in the docs.
I don't remember for ST, but for MSP430, I think it's 17 clocks. You have to check the docs to judge by yourself
if it's fast enough.

Beside this, detecting 1500 again when it rolls over doesn't make much sense. It means it would detect everytime
you cover the whole range (65k?) so whatever the value (1500 or not), the interrupt period will be the same.

Dora.
hi friends,

In STM32F412 microcontroller with HAL Library
I put timer 2 in encoder mode and everything works fine

I want, for example, if the counter reaches 1500, an interruption will occur, but I don't want the counter value to be reset after this interruption.
How can I do this?
I want the number 1500 to be recognized very quickly. When I check this value in the Super loop, every time the CPU may be involved in small delays (like LCD Update) and exceed the set value.


The things I did -> I thought it was possible to use timer 3 as a slave so that timer 3's clock is supplied from counter timer 2 But I was not successful



Thanks,
 
Last edited:

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top