pwm.c
来自「嵌入式系统mcf5272华恒光盘开发板附源代码pwm」· C语言 代码 · 共 38 行
C
38 行
/* *File: Pwm.c *Purpose: Initialize the PWM(Pulse Width Modulation) Module
* *Notes: Assume that thers is a LED linked to the output pins */#define MCF5272_PWM_PWMCR1 (0x0C0)#define MCF5272_PWM_PWWD1 (0x0d0)#define MCF5272_MBAR 0x10000000#include <stdio.h>main(){ if( getchar() == '1') { //disable the pwm,and output is low *(volatile unsigned char *)(MCF5272_MBAR + MCF5272_PWM_PWMCR1) = 0x04; usleep(2000000); //disable the pwm,and output is high *(volatile unsigned char *)(MCF5272_MBAR + MCF5272_PWM_PWMCR1) = 0x24; }else { //enable the pwm,and output is half high *(volatile unsigned char *)(MCF5272_MBAR + MCF5272_PWM_PWWD1) = 0x80; *(volatile unsigned char *)(MCF5272_MBAR + MCF5272_PWM_PWMCR1) = 0xA0; } printf("OK\n"); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?