📄 pwm.c
字号:
/* *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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -