当前位置: 首页 > news >正文

树莓派5 外设GPIO使能 PWM

系统版本:Raspberry OS

6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64 GNU/Linux

目标:使能外设引脚GPIO12 用作PWM功能

步骤:

1. 增加config.txt 配置

Pi:/$ cd /boot/firmware/overlays/
Pi:/boot/firmware/overlays$ ls pwm-2chan.dtbo
pwm-2chan.dtbo

Pi:/boot/firmware$ vi config.txt

add in endline:
dtoverlay=pwm-2chan

then reboot Raspiberry5

2. 配置GPIO12


Pi:~$ ls /sys/class/pwm/pwmchip
pwmchip0/ pwmchip2/
Pi:~$ ls /sys/class/pwm/pwmchip2/
device/    export     npwm       power/     subsystem/ uevent     unexport
Pi:~$ cd /sys/class/pwm/pwmchip2/
Pi:/sys/class/pwm/pwmchip2$ echo 0 > export
Pi:/sys/class/pwm/pwmchip2$ cd pwm0/
Pi:/sys/class/pwm/pwmchip2/pwm0$ ls
capture  duty_cycle  enable  period  polarity  power  uevent
Pi:/sys/class/pwm/pwmchip2/pwm0$ echo 20000 > period
Pi:/sys/class/pwm/pwmchip2/pwm0$ echo 10000 > duty_cycle

Pi:/sys/class/pwm/pwmchip2/pwm0$ pinctrl get 12
12: no    pd | -- // GPIO12 = none
Pi:/sys/class/pwm/pwmchip2/pwm0$ pinctrl set 12 a0
Pi:/sys/class/pwm/pwmchip2/pwm0$ pinctrl get 12
12: a0    pd | lo // GPIO12 = PWM0_CHAN0
Pi:/sys/class/pwm/pwmchip2/pwm0$
Pi:/sys/class/pwm/pwmchip2/pwm0$ echo 1 > enable

3. 在GPIO12上测量波形

相关文章:

  • DaVinci Resolve19.1下载:达芬奇调色中文版+安装步骤
  • 服务器ubuntu22.04上安装tiny-cuda-nn
  • STM32 + keil5 跑马灯
  • 深入理解 Apache Dagster:数据管道编排实战指南
  • 系统调用与中断
  • 鸿蒙学习手册(HarmonyOSNext_API16)_应用开发UI设计:Swiper
  • Swoole 的 Hyperf 框架和 Go 的 Gin 框架高并发原理以及技术实现对比分析
  • [C++面试] 智能指针面试点(重点)续4
  • 动手学深度学习:AlexNet
  • 从基础到实践(二十三):MCU选型设计指南
  • 避坑,c#开发人员学习开发app时.NET MAUI和Vue3 选择
  • 青少年编程与数学 02-013 初中数学知识点 04课题、图形与几何
  • 洛谷题单2-P1424 小鱼的航程(改进版)-python-流程图重构
  • [NCTF2019]Fake XML cookbook [XXE注入]
  • 第八部分:进程创建退出等待和替换
  • 深入探究C语言中的二进制世界:从原理到实践
  • 国产数据库突围,要过“生态关”
  • java多并发问题与解决办法以及为什么不能在多线程环境中使用非线程安全的集合?
  • ES 查看索引的属性的http请求
  • 2025年3月个人工作生活总结
  • 中科飞测将投资超10亿元,在上海张江成立第二总部
  • 外交部:中方对美芬太尼反制仍然有效
  • GDP逼近五千亿,向海图强,对接京津,沧州剑指沿海经济强市
  • SIFF动画单元公布首批片单:《燃比娃》《凡尔赛玫瑰》等
  • 外交部:正确认识和对待历史是检验日本能否恪守和平发展承诺的重要标准
  • 缺字危机:一本书背后有多少“不存在”的汉字?