OKI单片机——ML610Q4XX PWM
/***********************************************/
* @brief 初始PWM 引脚
* @details
/***********************************************/
void P43_Init(void)
{
P43DIR = 0;//P43 pin: Output (initial value)
P43C1 = 1;//CMOS output
P43C0 = 1;
P43MD1 = 1;//PWM0 output pin
P43MD0 = 0;
}
/***********************************************/
* @brief 串口 发送单字节数据
* @details Cycle值要大于Duty值
* @param[in] Cycle : 周期
* @param[in] Duty : 电平转换时间
/***********************************************/
void PWM_Init(uint16 Cycle,uint16 Duty)
{
PW0PH = (uint8)((Cycle-1)>>8);//周期
PW0PL = (uint8)(Cycle-1);
PW0DH = (uint8)((Duty-1)>>8);;//电平转换时间
PW0DL = (uint8)(Duty-1);
P0CS1 = 0;//LSCLK (initial value)
P0CS0 = 0;
P0IS1 = 0;//When the periods coincide. (Initial value)
P0IS0 = 0;
P0NEG = 0;//Positive logic (initial value)
P0RUN = 1;//Starts counting.
}