找回密码
 立即注册

QQ登录

只需一步,快速开始

打印 上一主题 下一主题
开启左侧

[MA35D1] Emulating PWM Capture via ECAP

[复制链接]
跳转到指定楼层
楼主
Application
This example code uses the ECAP function to emulate PWM Capture mode.
BSP Version
Linux-6.6.y
Hardware
NuMaker-HMI-MA35D1 V1.0

In real applications, the ECAP (Enhanced Input Capture Timer) is usually used together with QEI (Quadrature Encoder Interface). This is commonly used in motor detection and control systems. QEI decodes the encoder A/B phase signals to get the motor position and speed. By combining ECAP and QEI, the system can get both the motor mechanical position and speed at the same time.

However, this sample program uses the ECAP module to emulate the PWM capture mode function. It measures the frequency and duty cycle of an external PWM or pulse signal, and extends the ECAP usage range and flexibility in real systems.

The ECAP module built into the MA35D1 series microprocessor (MPU) can provide a measurement function similar to EPWM Capture mode. It can measure parameters such as the frequency and duty cycle of an external PWM or pulse signal.

The ECAP module provides multiple independent Input Capture units. Each unit includes the following features:

  • One 16-bit up-count timer/counter
  • Auto-reload and Compare-Match mechanism
  • Three independent input capture channels

Each capture channel can detect digital signal edge changes on the input pin (rising edge, falling edge, or both edges). When a configured edge event is detected, ECAP latches the current counter value into the related capture register.

By continuously reading the captured counter value difference between different edges (for example: rising-to-next-rising, rising-to-falling), the system can calculate:

  • Input PWM period (Period)
  • High level time (High Time)
  • Low level time (Low Time)
  • Duty cycle (Duty Cycle)

In this way, the ECAP module can emulate PWM input capture mode. It can accurately measure the timing features of an external PWM or other pulse signals. It can also work with interrupts to automatically move the measurement result to memory, reduce CPU load, and improve measurement efficiency.

You can download the sample code at EC_MA35D1_ECAP_Emulate_PWM_Capture_V1.00.


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 顶 踩
牛卧堂
回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

新唐MCU