方波控制时会用到比较多的斩波输出端口配置,下面给出了一直最常用的配置,以满足不同需求的功能要求
一共4组分别由MCPWM_IO01和MCPWM_IO23两个寄存器控制。
#define H_PWM_L_LOW 0x04上桥斩波,下桥关闭
#define H_PWM_L_PWM 0x00上桥和下桥都斩波
#define H_LOW_L_HIG 0x1c上桥关闭,下桥常开
#define H_LOW_L_PWM 0x08上桥关闭,下桥斩波
#define H_LOW_L_LOW 0x0c上桥和下桥同时关闭
#define H_HIG_L_LOW 0x2c上桥常开,下桥关闭
例如:
硬件默认配置为MCPWM_IO01 = 0x4141, MCPWM_IO23 = 0x4141其中A相由CH0控制,B相由CH1控制,C相由CH2控制。
A相悬空,B相上管斩波下管关闭,C相上管关闭下管常打开的配置为
{MCPWM_IO01 = PWM_01 | (H_LOW_L_LOW | (H_PWM_L_LOW << 8)); MCPWM_IO23 = PWM_23 | H_LOW_L_HIG;}
A相悬空,B相上管常开下管关闭,C相上管关闭下管常打开的配置为
{MCPWM_IO01 = PWM_01 | (H_LOW_L_LOW | (H_HIG_L_LOW << 8)); MCPWM_IO23 = PWM_23 | H_LOW_L_HIG;}
硬件默认配置为其他设置一样适用上述举例 |