This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

配置Timer为PWM模式

关于配置Timer为PWM模式,在AM335X Technical Reference Manual的20.1.3.5 Pulse-Width Modulation中有介绍,但客户在使用时反应实际进行编程操作时,存在一些困惑,且starterware中无相关例子可参考。

下面以在linux下的脚本为例,介绍配置步骤,starterware下可以在DTimer的例子中作相应修改。

其配置流程为:(以下是linux下的脚本,在linux下测试过,测试xdma_event_intr0有对应输出。同时说明下devmem2是linux下的读写物理内存的工具而已。)

(1)

# Enable Timer4's clock in CM_PER

# This allows us to access it's control regs

devmem2 0x44e00088 w 0x2

(2)

# Set the Pinmux for Timer4 (0x2 because its mode 2 of this pin)

# Using the pin mux linux driver from the SDK

echo 0x22 > /sys/kernel/debug/omap_mux/xdma_event_intr0

 

(3)

# Timer configurations.. Stop Timer.

# Auto-Reload

# Compare Mode Enabled

# Trigger set on overflow

# Toggle Mode

devmem2 0x48044038 w 0x1842

(4)

# Write to the CM_DPLL registers to select the clk source

# Selected the clk source for the Timer4

# This should be &= (default 0x12) (writing a 0x2 for 32kHz)

devmem2 0x44e00510 w 0x12

(5)

# Initial count value

devmem2 0x4804403C w 0xFFFFC000

 

# Set the re-load value

devmem2 0x48044040 w 0xFFFFC000

 

# Setting a duty cycle

devmem2 0x4804404C w 0xFFFFE000

 

(6)

# Start Timer

devmem2 0x48044038 w 0x1843

  • 您好,如果想在linux初始化的过程中,设置TIMER7为PWM输出方式,该改哪里呢?

  • 上面给出来的流程基本上都是寄存器级的操作,只有设置pinmux那处,就是改control module下面的相关寄存器。其他部分,对应的你在Linux初始化中这样操作就可以了。

  • 我目前是在u-boot里面直接操作寄存器的方式实现的,

    这样有个问题,linux里面diable_clk_unused会把timer7的时钟关闭,

    因为我把 static __initdata struct omap_hwmod *am33xx_hwmods[] 里面的timer7删除了,

    我的想法是,linux初始化的时候肯定可以直接设置timer7的寄存器,

    但是我一直没找到在哪个文件里面定义这些寄存器的实际值。

  • 执行第四步时(devmem2 0x44e00510 w 0x12),报下列错误
     /dev/mem opened
    Memory mapped at address 0xb6f29000.
    Read at address 0x44E00510 (0xb6f29510): 0x00000000
    Write at address 0x44E00510 (0xb6f29510): 0x00000012, readback 0x00000012
    root@am437x-evm:/# devmem2 0x4804403C w 0xFFFFC000
    /dev/mem opened.[ 3212.498147] Unhandled fault: external abort on non-linefetch (0x1018) at 0xb6ff303c
    [ 3212.507120] ------------[ cut here ]------------
    [ 3212.511772] WARNING: CPU: 0 PID: 1699 at drivers/bus/omap_l3_noc.c:147 l3_interrupt_handler+0x234/0x35c()
    [ 3212.521379] 44000000.ocp:L3 Custom Error: MASTER M2 (64-bit) TARGET L4_PER_0 (Read): Data Access in User mode during Functional access
    [ 3212.533512] Modules linked in: btwilink bluetooth ads7846 c_can_platform c_can dwc3_omap can_dev snd_soc_davinci_mcasp 6lowpan_iphc [last unloaded: dmtimer_pwm]
    [ 3212.547991] CPU: 0 PID: 1699 Comm: devmem2 Tainted: G W O 3.14.43 #6
    [ 3212.555066] Backtrace: 
    [ 3212.557544] [<c001115c>] (dump_backtrace) from [<c00112f8>] (show_stack+0x18/0x1c)



  • 想知道如何配置引脚复用和设备树实现
x 出现错误。请重试或与管理员联系。