Tool/software:
How to enable TIMER in Capture mode in Linux ?
I am attaching the patches for enabling Capture using timer IO :
Uboot Driver Changes:
0001-TIMER-CAPTURE-DTBO-ENV-OVERLAY.patch
Linux Driver Changes:
0001-TIMER-CAPTURE-DRIVER-CHANGES.patch
Linux Device tree Changes:
1072.0002-TIMER-CAPTURE-DTS-changes.patch
DTBO:
Steps:
>make u-boot >make linux
#!/bin/bash #set -x cd /sys/class/pwm/pwmchip0 echo 0 > export #Will export pwm0 device cd pwm0/ echo 100000000 > period #In nanoseconds echo 30000000 > duty_cycle #In nanoseconds echo "normal" > polarity echo 1 > enable while true do cat capture sleep 2 done
devmem2 0x02400038 w 0x00004043
2) Also, TIMER0 enables PWM by default as per default value of registers. Attached here for reference.
So, by default all TIMERIOs out is controlled by TIMER0.
Note :
Ensure that the uENV.txt file "name_overlays" parameter(if present) does not overwrite the name_overlays parameter given in the patch 0001-TIMER-CAPTURE-DTBO-ENV-OVERLAY.patch.
Limitations:
The time period values are captured correctly.
However, the duty cycle values may not be accurate as timer has only 2 capture registers and these registers can be captured with cap1 in rising and cap2 in falling or vice versa. Hence, either (duty cycle) or (1-duty_cycle) will be captured. This is a hardware limitation of the IP actually.
Regards
Gokul