1.参考C:\Texas Instruments\Z-Stack Lighting 1.0.2\Components\hal\target\CC2530PMP4712例程里的hal_timer.h和hal_timer.c文件(这两个文件没任何修改)
测试发现只有P0.6脚才能输出PWM,配置如下
#define INIT_PWM_PINS()
{
PERCFG |= 0x40;
P0SEL |= 0x40;
P0DIR |= 0x40;
}
#define PWM1 HAL_T1_CH4 //P0.6
HalTimer1Init(0);//初始化定时器
halTimer1SetChannelDuty (PWM1,500);//占空比50%
此时正常输出50%占空比方波
2.当想要设置P0.3和P0.4两路同时输出PWM时,发现没有任何波形,配置如下
P0.3和P0.4其他地方也没用啊
#define INIT_PWM_PINS()
{
PERCFG &= ~0x40;
P0SEL |= (0x08|0x10);
P0DIR |= (0x08|0x10);
}
#define PWM1 HAL_T1_CH1//P0.3
#define PWM2 HAL_T1_CH2//P0.4
HalTimer1Init(0);//初始化定时器
halTimer1SetChannelDuty (PWM1,500);//占空比50%