Arduino_core_stm32: Encoder Mode on Stm32f103c8

Created on 3 Sep 2019  路  5Comments  路  Source: stm32duino/Arduino_Core_STM32

Is there feature where I can use the timers in the encoder mode in STM32f103c8. @fpistm
Annotation 2019-09-03 163853
Annotation 2019-09-03 163756

Question

Most helpful comment

Hi @pasindu-sandima,
The HardwareTimer API https://github.com/stm32duino/Arduino_Core_STM32/pull/576
doesn't support encoder mode. But any contribution is welcome.
Nevertheless it is still possible to use STM32Cube API (HAL or LL) to access encoder mode.
Note: HAL/LL API can be used directly in your arduino sketch.

All 5 comments

@pasindu-sandima
There is no dedicated Arduino API to use it.
You can use the encoder feature using HAL/LL or direct register access.
Hereafter the HAL one.
https://github.com/stm32duino/Arduino_Core_STM32/blob/e638225486c529bf787735d6a14ddd326156f015/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h#L1692-L1705

Hi @pasindu-sandima,
The HardwareTimer API https://github.com/stm32duino/Arduino_Core_STM32/pull/576
doesn't support encoder mode. But any contribution is welcome.
Nevertheless it is still possible to use STM32Cube API (HAL or LL) to access encoder mode.
Note: HAL/LL API can be used directly in your arduino sketch.

@ABOSTM I tried to compile the code generated from CubeMX in arduino. But it did not work. Is there any specific way that I can use HAL library in arduino sketches??

@pasindu-sandima, there is no specific way.
I am not sure to understand what you mean by 'compile the code generated from CubeMX in arduino':
CubeMX doesn't manage specific arduino functions like setup() and loop(), so you need to copy piece of code from CubeMX within setup() or loop() in your arduino sketch.
Also what kind of issue do you have ? compiler error, runtime error ?

I had a compiler error. But now I tried doing direct register editing and now its working. Thanks a lot for your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcer12 picture mcer12  路  3Comments

ladyada picture ladyada  路  5Comments

fivdi picture fivdi  路  6Comments

Pararera picture Pararera  路  5Comments

Hoel picture Hoel  路  4Comments