[FAQ] TDA4VH: TIMER in Capture Mode.

Part Number: TDA4VH


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:

    k3-j784s4-dmtimer-cap.dtbo

    Steps:

    • Apply all the patches above.
    • Once these patches are applied, recompile uboot and linux by running the below commands from the SDK directory:
      • >make u-boot
        >make linux
    • Copy the following files to boot directory of sd card:
      • <SDK dir>/board-support/<u-boot dir>/build/r5/tiboot3.bin
      • <SDK dir>/board-support/<u-boot dir>/build/a72/tispl.bin
      • <SDK dir>/board-support/<u-boot dir>/build/a72/u-boot.img
    • Copy the following files to <SD CARD root directory>/boot
      • <SDK dir>/board-support/<linux dir>/arch/arm64/boot/Image
    • Copy the following files to <SD CARD root directory>/boot/dtb/ti
      • <SDK dir>/board-support/<linux dir>/arch/arm64/boot/dts/ti/k3-j784s4-evm.dtb
      • k3-j784s4-dmtimer-cap.dtbo file attached above.
    • Run the below script to start the capture
      • #!/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
    • Set the GPO_CFG bit of TIMER_TCLR register for TIMER0 as 1(Capture mode) using the below commands:

    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