Skip to main content
vbuon.1
Associate III
November 11, 2021
Solved

Is there an API for accessing the timers (TIMx)?

  • November 11, 2021
  • 3 replies
  • 1088 views

hi,

i would like to know if there is an API for configuring, starting and stopping the timers (TIM1, TIM2, etc.) i'm interested in setting up a timer as a PWM device. i've come across documentation that talks about functions that can be used to set up a timer as a PWM device (e.g., pwm_apply_state, pwm_config, pwm_enable, etc.) but i can't find any documentation that describes these functions, the name of the library they are in or the header file to include. no can i find examples on how to use the API. i found examples on adding nodes to a device tree and how to use the sysfs interface. but, i would prefer to use a library if it exists.

thank you,

vincent j. buonassisi

This topic has been closed for replies.
Best answer by vbuon.1

hi,

thank you for your response. the post was the most helpful. it seems that there is no library to access the timers. the easiest way w/o having to write my own driver was to use c/c++ file i/o calls. i can use either the higher level calls (e.g., fopen, fprintf, etc.) or the low level ones (.e.g, open, write, etc.)

thanks,

vince

3 replies

PatrickF
Technical Moderator
November 12, 2021

Hi,

Please have a look to this wiki page which provide links to SW framework usable with TIMx

https://wiki.st.com/stm32mpu/wiki/TIM_internal_peripheral#Software_frameworks

in particular, I see this API https://wiki.st.com/stm32mpu/wiki/PWM_overview#Example_of_PWM_usage_with_kernel_PWM_API

See also this post: https://community.st.com/s/question/0D53W000014W92lSAC/pwm-kernel-driver-api

Regards,

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.NEW ! Sidekick STM32 AI agent, see here
PatrickF
Technical Moderator
November 22, 2021

Hi,

Did the answer above helped you ?

Regards.

In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.NEW ! Sidekick STM32 AI agent, see here
vbuon.1
vbuon.1AuthorBest answer
Associate III
November 23, 2021

hi,

thank you for your response. the post was the most helpful. it seems that there is no library to access the timers. the easiest way w/o having to write my own driver was to use c/c++ file i/o calls. i can use either the higher level calls (e.g., fopen, fprintf, etc.) or the low level ones (.e.g, open, write, etc.)

thanks,

vince