2022-06-08 05:40 AM
Hi,
I am using STM32MP153a SOC.Linux kernel version is 5.4.56 (openstlinux-5.4-dunfell-mp1-20-11-12).
I would like to generate square signal of 50-200 uS on a certain GPIO every 40 ms using Linux kernel.Also ,at this point I need to read certain registers.
What are my options? If there is already an example/application note on the subject,please let me know.
I was looking into these options:
1)I have already a working timer on my system,which is arm arch timer.It's already generating interrupts ( I can see that number of interrupts is increasing in /proc/interrupts).The question is how do I configure it to generate interrupt every 40 ms and I how do I generate callback to have my registers reading.
2)TIM6/TIM12 -STM32 timer.
As far as I could see,current examples - pwm,counter,trigger ,does not fit my needs , since they don't have any form of periodic interrupt.
PWM example is the closest to what I need - it possibly could generate a signal that I need,but it doesn't have an option to have an interrupt function to read those registers
3)"st,stm32-timer" - I have stumbled into this option while digging throught the kernel source tree.It has clocksource and clockevents implementation ,but it seems that it works only with STM32F series.If it could work with TIMs of STM32MP15x series,please let me know.Also an example of usage would be useful.
Thank You!
Solved! Go to Solution.
2022-08-04 09:23 AM
Hello @vl4ever ,
This question was internally handled by me, so I will summaries here the information.
After a lot of tries on my side with TIM2, I asked an expert that confirmed me that the driver of Timer doesn't support the periodic interrupts.
At hardware level it is supported and the register UIF is raised, but there is no mechanism at driver level that throw an interrupt.
This feature of doing a periodic timer can be done easily by software, which avoid to clock the hardware.
For instance:
https://qnaplus.com/how-to-implement-periodic-timer-in-linux-kernel/
This link show how to do a periodic timer in a linux driver with an handler.
Some of these functions have a new name like "setup_timer" which is now "timer_setup".
https://lwn.net/Articles/735887/
I think this software solution, to use a software periodic timer that calls your function that reads registers, fills your need.
Hope it helps,
Regards,
Kevin
2022-08-04 09:23 AM
Hello @vl4ever ,
This question was internally handled by me, so I will summaries here the information.
After a lot of tries on my side with TIM2, I asked an expert that confirmed me that the driver of Timer doesn't support the periodic interrupts.
At hardware level it is supported and the register UIF is raised, but there is no mechanism at driver level that throw an interrupt.
This feature of doing a periodic timer can be done easily by software, which avoid to clock the hardware.
For instance:
https://qnaplus.com/how-to-implement-periodic-timer-in-linux-kernel/
This link show how to do a periodic timer in a linux driver with an handler.
Some of these functions have a new name like "setup_timer" which is now "timer_setup".
https://lwn.net/Articles/735887/
I think this software solution, to use a software periodic timer that calls your function that reads registers, fills your need.
Hope it helps,
Regards,
Kevin