⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwm.c

📁 嵌入式系统mcf5272华恒光盘开发板附源代码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 + -