|
void PWM_Init()
{
PWM0_L = 0;
PWM1_L = 0;
PWM2_L = 0;
HDU = 0;
HDV = 0;
HDW = 0;
//0x 01110000
P3M1 &= ~0x70;
P3M0 |= 0x70;
// CMOD = 1 << 1; // 选择系统时钟/2为时钟源 PWM频率=24M/2/256=46.9K
CMOD = 5 << 1; //CMOD寄存器配置 选择系统时钟/4为时钟源 PWM频率24M/4/256=23.4K
CL = 0; //PCA 计数器清零
CH = 0;
PCA_PWM0 = 0X00; //PCA_PWM0工作于8位PWM功能
CCAP0H = 0;
CCAP0L = 0;
CCAPM0 = 0x42; //0x 0100 0010 设置PWM模式
PCA_PWM1 = 0X00;
CCAP1H = 0;
CCAP1L = 0;
CCAPM1 = 0x42;
PCA_PWM2 = 0X00;
CCAP2H = 0;
CCAP2L = 0;
CCAPM2 = 0x42;
CR = 1; //PCA定时器开始工作
}
void main()
{
MCU_IOinit();
USER_Delay_MS(50);
OLED_Init();
USER_Delay_MS(100);
OLED_Clear();
USER_Delay_MS(100);
//OLED_ShowChar(0,6,'V',16);
OLED_DrawBMP(0,0,77,32,BMP1);
USER_Delay_MS(600);
Motor_flag = 0;
motor_MO = 0;
//bitch1 = 0;
//flag = 0;
PWM_Init();
ADC_Init();
//CMP_Init();
//EA = 1;
while (1)
{
;
}
|
|