Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 22 Jan 2015 02:55 PM by  Adam Ford
How to Enable Backlight PWM in Logic Loader
 0 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Adam Ford
Advanced Member
Advanced Member
Posts:794


--
22 Jan 2015 02:55 PM
    # File 

    #     dm37x_omap35x_gpt10_pwm.losh

    #
    # Purpose 
    #     To test hardware using PWM connected to SOM (uP_nCS5) / GPT10_PWM, connection on Baseboard J30.26 of Torpedo
    #
    # Input Variables - (Default set below.  Must be commented out below if if desired to pass in variables)
    #     Clock_SYS :
    #              0  => CM_32K_CLK
    #              1  => CM_SYS_CLK (26MHz)
    #     Pulse :
    #              0  => low pulse
    #              1  => high pulse
    #     Sample_Divisor :
    #              0  => Clock not changed
    #              1  => Clock divided by 32
    #
    # Return
    #     None
    #
    # Required Scripts
    #     none
    #
    # Notes:
    #  Valid Settings -
    #    TLDR_GPT10 must be smaller than TMAR_GPT10 to see a pulse
    #  
    #  Period -
    #    To increase the period, lower the value written to TLDR_GPT10.
    #    This value can be changed while the PWM is running.
    #      losh>  w /w $TLDR_GPT10  0xFFFFFFF0 (default)
    #
    #  Pulse Width -
    #    To increase the pulse width, lower the value written to 
    #    This value can be changed while the PWM is running.
    #      losh>  w /w $TMAR_GPT10 0xFFFFFFF8  (default)
    #
    #  PWM Controller Limitations:
    #     1.  Do not put the overflow value (0xFFFF FFFF) in the GPTi.TLDR register
    #     because it can lead to undesired results.
    #     2.  TLDR_GPT10 and TMAR_GPT10 must keep values smaller than the overflow value
    #     (0xFFFF_FFFF) by at least two units.
    #     3.  TLDR_GPT10 and TMAR_GPT10 must be kept difference must be a minimum of two
    #     units.
    #
    #
    # Version 1.0 
    #
    # © Copyright 2010, Logic Product Development, Inc.  All Rights Reserved.

    # Comment out these variable if control is desired outside this script.
    Clock_SYS = 0
    Pulse = 1
    Sample_Divisor = 0


    # Notes
    # GPTi.TLDR[31:0]
    # GPTi.TCLR[5] PRE    GPTi.TCLR[4:2] PTV      Divisor (PS)
    # 0                          X                      1
    # 1                          0                      2
    # 1                          1                      4
    # 1                          2                      8
    # 1                          3                      16
    # 1                          4                      32


    # Clocks
    #PRCM.CM_CLKSEL_CORE [6] CLKSEL_GPT10
    PRCM.CM_CLKSEL_CORE            =  0x48004A40
    PRCM.CM_CLKSEL_CORE.CM_SYS_CLK = 1 << 6
    x /w $PRCM.CM_CLKSEL_CORE
    #0x48004a40  0000030a
    CLKSEL_CORE_VAL = $@
    # set GPT10 clock source to CM_SYS_CLK
    CLKSEL_CORE_VAL = $CLKSEL_CORE_VAL | $PRCM.CM_CLKSEL_CORE.CM_SYS_CLK
    if ($Clock_SYS)
       w /w $PRCM.CM_CLKSEL_CORE $CLKSEL_CORE_VAL
    endif

    #PRCM.CM_FCLKEN1_CORE [11] EN_GPT10 bit
    x /w 0x48004A00
    w /w 0x48004A00 0x0100a800

    #PRCM.CM_ICLKEN1_CORE [11] EN_GPT10 bit
    x /w 0x48004A10
    w /w 0x48004A10 0x0100a842

    echo "\nControl Padconfig GPMC_nCS5"
    #read CONTROL_PADCONF_GPMC_NCS5 value
    CONTROL_PADCONF_GPMC_NCS5 =  0x480020B8
    x /w $CONTROL_PADCONF_GPMC_NCS5
    #Set CONTROL_PADCONF_GPMC_NCS5 mode3, output
    w /w $CONTROL_PADCONF_GPMC_NCS5 0x01180003 

    # Reset (verify GPT10 is not in reset)
    TCLR_TISTAT_GPT10 = 0x48086014
    x /w $TCLR_TISTAT_GPT10
    reset = !$@
    while ($reset)
    x /w $TCLR_TISTAT_GPT10
    reset = !$@
    done

    #Read TCLR.GPT10
    TCLR_GPT10 = 0x48086024
    x /w $TCLR_GPT10
    #0x48086024  00000000

    echo "\nControl Register (Stop the Timer)"
    TCLR_GPT10 = 0x48086024
    w /w $TCLR_GPT10 0x0

    echo "\nLoad Register"
    #Load Timer Value
    TLDR_GPT10 = 0x4808602C
    w /w $TLDR_GPT10  0xFFFFFFF0
    x /w $TLDR_GPT10

    echo "\nMatch Register"
    #Write TMAR.COMPARE_VALUE
    TMAR_GPT10 = 0x48086038
    w /w $TMAR_GPT10 0xFFFFFFF8

    echo "\nPreset Counter"
    TCRR_GPT10 = 0x48086028
    x /w $TCRR_GPT10
    w /w $TCRR_GPT10 0xFFFFFFFE

    echo "\nRead Counter"
    TCRR_GPT10 = 0x48086028
    x /w $TCRR_GPT10 

    echo "\nRead Status"
    TISR_GPT10 = 0x48086018
    x /w $TISR_GPT10

    echo "\nClear Status"
    TISR_GPT10 = 0x48086018
    w /w $TISR_GPT10 0x7

    echo "\nRead Status"
    TISR_GPT10 = 0x48086018
    x /w $TISR_GPT10

    echo "\nControl Register (Enable the Timer)"
    #Write TCLR.GPT10, Default value of PWM_output = 1 (TCLR.GPT10.SCPWM = 1) and start timer
    TCLR_GPT10_PT       = 1 << 12   # Set for Toggle modulation, Clear for Pulse modulation
    TCLR_GPT10_TRG_O_M  = 2 << 10   # Overflow and Match
    if ($Pulse)
       TCLR_GPT10_SCPWM = 0 << 7    # Set to default value of PWM_out low
    else
       TCLR_GPT10_SCPWM = 1 << 7    # Set to default value of PWM_out high
    endif
    TCLR_GPT10_CE       = 1 << 6    # Set to compare on match
    if ($Sample_Divisor)
       TCLR_GPT10_PRE   = 1 << 5    # Enable prescaler
       TCLR_GPT10_PTV   = 4 << 2    # Set prescaler eq 4
    else
       TCLR_GPT10_PRE   = 0 << 5    # Enable prescaler
       TCLR_GPT10_PTV   = 0 << 2    # Set prescaler eq 4
    endif
    TCLR_GPT10_Reload  = 1 << 1    # Set to Autoreload mode
    TCLR_GPT10_Start   = 1 << 0    # Set to start the timer
    TCLR_GPT10_Value   = ( $TCLR_GPT10_PT | $TCLR_GPT10_PRE | $TCLR_GPT10_CE | $TCLR_GPT10_PTV | $TCLR_GPT10_TRG_O_M | $TCLR_GPT10_SCPWM | $TCLR_GPT10_CE | $TCLR_GPT10_Reload | $TCLR_GPT10_Start)
    w /w $TCLR_GPT10  $TCLR_GPT10_Value
    # Read Control Register
    x /w $TCLR_GPT10





    You are not authorized to post a reply.