Close

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

forlinx-embeddedforlinx embedded wrote 11/01/2024 at 06:53 • 4 min read • Like

Description

PWM (Pulse Width Modulation) is very common in embedded systems. It provides a method for generating pulse periodic wave-forms for motor control or can function as a digital-to-analog converter with some external components.

RK3562 supports 16 interrupt-driven on-chip PWM channels and offers capture mode with the following features:

The capture mode of the RK3562 uses the PWM channel clock to measure the high/low effective periods of the PWM channel input waveforms and generates interrupts when the polarity of the input waveform changes. It can also capture the pulse counts of the input waveform, which can be used to measure waveform information such as duty cycle and frequency.

Application Scenario

PWM capture is a technique used to measure the cycle, frequency, and duty cycle of external signals. In the power sector, real-time data acquisition is essential for analyzing and monitoring grid power due to the normal fluctuations in grid frequency. The PWM capture technology can be utilized to detect grid frequency in real-time.

This article will use a signal generator to produce square waves of specific frequencies to simulate signal input in real application scenarios and provide a simple demonstration of the PWM capture function of the RK3562.

Cases

Development Board Model: OK3562-C + FET3562J-C

Forlinx Material Version: OK3562-C_Linux 5.10.198_User Manual_R1

Development Board System: Linux 5.10.198 (CPU0, 1, 2) + RT-Thread (CPU3)

Hardware Preparation:

One set of OK3562-C development board

One signal generator

Several Dupont wires

Software Preparation:

Please contact Forlinx to get it!

Source Code Compilation:

Extract the source code and enter the OK3562-linux-source directory

Execute ./build.sh defconfig:forlinx_ok3562_linux_rtos_defconfig to change the compilation configuration to run Linux on 3 CPUs and RT-Thread on 1 CPU in AMP mode;

Execute ./build.sh for a full compilation and wait for the process to complete;

The compiled update.img image is saved in the rockdev directory.

Testing Steps:

1. Follow the user manual in the software materials to burn the image. After burning, power on the device; RT-Thread will print the following:

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

2. Execute fl_pwmcap to enable PWM capture functionality and start detecting the input signals. Successful startup will appear as shown below:

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

3. Turn on the signal generator and change the output mode to continuous pulse waveform, with a frequency set to 10 kHz and a duty cycle of 90%.

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

After enabling the output of the signal generator, the board will start printing the measured period and duty cycle (the 89% duty cycle is due to the program's calculation not preserving decimal points, causing some errors).

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

Change the duty cycle of the signal generator to 30%, and the board output will reflect this change to 30%.

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

Change the frequency of the signal generator to 500 kHz and duty cycle to 75%, and continue observing the board output:

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

Introduction to the PWM Capture Function of the Rockchip RK3562 Platform and Application Cases

Like

Discussions