Is there feature where I can use the timers in the encoder mode in STM32f103c8. @fpistm


@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.
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.