导航

    Freqchip开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 最新
    1. 主页
    2. 热门
    3. 周
    • 日
    • 周
    • 月

    • C

      FR2102例程在哪找
      FR201x • • CC

      4
      0
      赞同
      4
      帖子
      141
      浏览

      Z

      @cc https://www.freqchip.com/fr200x 官网下载
    • S

      FR8016HA LED1/LED2脚可以做PWM功能吗?
      FR801xH • • summer

      2
      0
      赞同
      2
      帖子
      38
      浏览

      F

      @summer #include "driver_pmu.h" #include "driver_pmu_pwm.h" #include "driver_system.h" void led2_pwm_example(void) { pmu_pwm_init(); pmu_set_led2_as_pwm(); // 配置 LED2 为 PMU PWM 模式(固定为 PWM2) // 获取 RC 时钟频率(约 62.5KHz) uint32_t rc_freq = pmu_get_rc_clk(false); // 目标:2 Hz,占空比 50% #define TARGET_FREQ 2 // 2 Hz,闪烁可见 #define DUTY_PERCENT 50 // 每个计数单位 = 2 / rc_freq 秒 uint32_t total = (rc_freq / 2) / TARGET_FREQ; uint16_t high = total * DUTY_PERCENT / 100; uint16_t low = total - high; // 设置 PWM2 参数(用 PA2 作为代理,因为 (0*8+2)%4 = 2) pmu_pwm_set_param(GPIO_PORT_A, GPIO_BIT_2, high, low); // 停止并复位计数器 pmu_pwm_stop(GPIO_PORT_A, GPIO_BIT_2); // 启动连续输出,极性不反转 pmu_pwm_start(GPIO_PORT_A, GPIO_BIT_2, true, false); }