RD8T36 PWM输出,输出的IO是P50,MCU的42脚,PW0,原计划是准备用43脚PWM4做个灯体现出来的,偷懒,没来的及弄。输出10KHz的占空比为25%的PWM波形。
使用的工具是便捷的示波器,抓IO口的波形。
请忽略这个波形的多余部分,表笔问题,没有调好。
代码:
PWM初始
if(PWM_GetFlagStatusEX(PWM0_Type)) //获取中断标志位状态并判断
{
PWM_ClearFlagEX(PWM0_Type);
//PWM_DutyChange_Up ; //占空比增加
//PWM_DutyChange_Dowm; //占空比减小
GPIO_TogglePin(GPIO0, GPIO_PIN_4); //P04翻转
}
//PWM对齐模式
typedef enum
{
PWM0_Edge_Aligned_Mode = (uint8_t)0x00, //PWM边沿对齐模式
PWM0_Center_Alignment_Mode = (uint8_t)0x01, //PWM中间对齐模式
} PWM_Aligned_Mode_TypeDef;
//PWM引脚复用选择
typedef enum
{
PWM_OUTPUTSTATE_DISABLE = ((uint8_t)0x00), //该PIN脚作为GPIO
PWM_OUTPUTSTATE_ENABLE = ((uint8_t)0x01) //该PIN脚作为PWM
} PWM_OutputState_TypeDef;
//PWM输出正反向选择
typedef enum
{
PWM_POLARITY_NON_INVERT = ((uint8_t)0x00), //PWM输出不反向
PWM_POLARITY_INVERT = ((uint8_t)0x01) //PWM输出反向
} PWM_Polarity_TypeDef;
//PWM占空比改变方向
typedef enum
{
PWM_DutyChange_Up = (uint8_t)0x01, //PWM占空比增加
PWM_DutyChange_Dowm = (uint8_t)0x00, //PWM占空比减少
}
PWM0 = (uint8_t)0x01, //PWM输出通道选择:PWM0
PWM1 = (uint8_t)0x02, //PWM输出通道选择:PWM1
PWM2 = (uint8_t)0x04, //PWM输出通道选择:PWM2
PWM3 = (uint8_t)0x08, //PWM输出通道选择:PWM3
PWM4 = (uint8_t)0x10, //PWM输出通道选择:PWM4
PWM5 = (uint8_t)0x20, //PWM输出通道选择:PWM5
PWM6 = (uint8_t)0x40, //PWM输出通道选择:PWM6
后面再更新,,,
|