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