PWM实验

 

 

#include"exynos_4412.h"
void Delay( unsigned int Time)
{
 while(Time--);
}
int main()
{
	/*1.将GPD0_0设置成输出功能*/
	GPD0.CON = GPD0.CON & (~(0xF)) | (0x2);
	/*2.设置PWM的一级分频,1级分频倍数为100倍*/
     PWM.TCFG0= PWM.TCFG0 &(~(0xF)) | 99;
	 /*3.设置PWM的二级分频,倍数为1*/
	 PWM.TCFG1 = PWM.TCFG1 & (~(0xF));
      /*4.设置PWM为自动重装载,使其能够产生连续的脉冲信号*/
	 PWM.TCON = PWM.TCON|(1<<3);
	 /*设置PWM的频率为1000Hz*/
	  PWM.TCMPB0 = 1000;
/*6.设置PWM的占空比为60%;*/
	  PWM.TCMPB0 = 600;
	  /* 7.将TCNDB0中的值装载到递减计数器中*/
	  PWM.TCON = PWM.TCON | (1<<1);
	  /*8.关闭手动更新*/
	  PWM.TCON = PWM.TCON | (~(1<<1));
	  /*使能pwm0,递减计数器开始递减*/
	  PWM.TCON = PWM.TCON | 1;

	  while(1)
	  {
	  PWM.TCON = PWM.TCON | 1;
      Delay(1000000); 
	  PWM.TCON = PWM.TCON | 1;
      Delay(1000000); 
	  }
	return 0;
}

你可能感兴趣的:(算法)