My FeedDiscussionsHeadless CMS
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Omar Hiari

5 comments

juebanlin
juebanlin
Sep 14, 2023

In the stm32 hal environment:

How can a 4 PIN (GND VCC FG PWM) PWM fan current speed be read through the fan FG pin?

Timer mode statistics or exti interrupt? Can you provide examples separately? Thank you.

·
·4 replies
Omar Hiari
Omar Hiari
Author
·Sep 14, 2023

Hello juebanlin and thanks for reading. There are several ways to achieve that. I Ideally, I would use something like input capture mode in a timer. However, the last I used the STM HALs most, if not all, did not support input capture mode yet. I figure you can implement using the PAC, but that might be a bit of a hassle.

Another way around it is by using GPIO similar to something in this post. Although using ESP, it should map more or less in a similar manner to the STM. Also, you can achieve the same using GPIO interrupts if you want to avoid polling. The ISR would instead inform you that the event happened.

·
juebanlin
juebanlin
Sep 14, 2023

Omar Hiari If using HAL, I can only rely on polling or EXTI interrupts to count, because I also don't want to use PAC, which is too complicated.

Although Trust stm32 hal is very convenient, there are many APIs and usage methods for the hal library that do not provide examples of how to use them. I hope you can provide more examples of how to use the hal library in the future.

For example, I learned from you about non blocking examples such as HAL library timers.

Can you write more examples of HAL libraries combined with various peripherals? For example, EC11 signal input, PWM FG signal input

·
Omar Hiari
Omar Hiari
Author
·Sep 14, 2023

juebanlin I have created a full STM32 strictly hal-based series in the past that you can find here. There is also a series using the STM32 with embassy. The closest example to what you are looking for is probably the ultrasonic measurement with timers.

Regarding more examples, that is always a goal, but time is always tight, and I am always trying my best to generate more. As for the FG input, I don't have such hardware readily available but the concept of how to measure is largely similar to examples I already developed. For example, the earlier example I shared about the squarewave generator input connected the ESP, that would be exactly the same logic you would utilize to measure the frequency of an FG signal.

·
juebanlin
juebanlin
Sep 15, 2023

Omar Hiari Thank you very much. I will continue to follow you and hope you can publish more articles about Trust embedded

1
·