TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2F PWM 占空比为0 管脚还有输出

CC2640R2F  PWM 设置占空比为0时, PWM管脚还有输出, PWM管脚能输出低电平吗?

程序配置如下

#define PWMOUT1_DUTY                     0

#define PWM_DUTY                         1000

#define PWM_FREQUENCE 100000ul
#define PWM_TIM_LOAD_VAL (uint32_t)(48000000ul / PWM_FREQUENCE)
#define PWM_METCH_VAL(X) (uint32_t)(PWM_TIM_LOAD_VAL * X / PWM_DUTY)

void PWM_Init(void)
{

pinHandle = PIN_open(&pinState, PWMPinTable);

Power_setDependency(PowerCC26XX_XOSC_HF); 
Power_setDependency(PowerCC26XX_PERIPH_GPT0);
PINCC26XX_setMux(pinHandle, PWMOUT1_PIN, IOC_PORT_MCU_PORT_EVENT0);

TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM );
HWREG(GPT0_BASE + GPT_O_CTL) &= ~(GPT_CTL_TAEN); 
TimerLevelControl(GPT0_BASE, TIMER_A, TRUE);
HWREG(GPT0_BASE + GPT_O_TAILR) = PWM_TIM_LOAD_VAL;
HWREG(GPT0_BASE + GPT_O_TAMATCHR) = PWM_METCH_VAL(PWMOUT1_DUTY);
PWM_SetDuty( PWMOUT1_DUTY);

HWREG(GPT0_BASE + GPT_O_CTL) |= (GPT_CTL_TAEN);

}

void PWM_SetDuty(,uint16 duty)
{

if(duty == 0)
{
HWREG(GPT0_BASE + GPT_O_TAMATCHR) = (uint32)0;
}
else if(duty == PWM_DUTY)
{
HWREG(GPT0_BASE + GPT_O_TAMATCHR) = (uint32)PWM_TIM_LOAD_VAL-1;
}
else
{
HWREG(GPT0_BASE + GPT_O_TAMATCHR) = PWM_METCH_VAL(duty);
}

}

Alvin Chen:

请使用TI提供driver 接口:
C:\ti\simplelink_cc2640r2_sdk_3_10_00_15\examples\rtos\CC2640R2_LAUNCHXL\drivers\pwmled2

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F PWM 占空比为0 管脚还有输出
分享到: 更多 (0)