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

【急,在线等!!!!】使用timer 设置PWM问题

用事例代码设置PWM的频率不能设置频率小于700HZ的,应该是定时器设置为16位的原因,怎么样设置32位定时器,可以产生700HZ以下频率的PWM,

static void board_pwm_init()
{
Power_setDependency(PERIPH_GPT1);
TimerConfigure(GPT1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_CAP_COUNT);
//TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_CAP_COUNT);
}

void board_pwm_audio(unsigned long freq_Hz, uint8 duration)
{ unsigned long PWM_FREQ = freq_Hz;
unsigned long PWM_DIV_FACTOR = 48000000/PWM_FREQ;
unsigned long TIMER_LOADSET = (PWM_DIV_FACTOR-1);
unsigned long TIMER_MATCH;
if(duration > 100)
duration = 100;
TIMER_MATCH = (PWM_DIV_FACTOR*(100-duration)/100-1);
pr_info("freq_Hz=%d duration=%d \n",freq_Hz,duration);
TimerLoadSet(GPT1_BASE,TIMER_A,TIMER_LOADSET); TimerDisable(GPT1_BASE, TIMER_A);
PINCC26XX_setMux(hAudio_Pins, Board_AUDIO_PWM, IOC_PORT_MCU_PORT_EVENT2); TimerMatchSet(GPT1_BASE,TIMER_A,TIMER_MATCH);
TimerEnable(GPT1_BASE,TIMER_A);
}

Elvis Chen:

分频也行啊,怎么弄啊,给个方法撒。。。。。

Barbara Wu:

回复 Elvis Chen:

看起来可以尝试用timer3或者timer4来做 这个两是8bit的

请参考如下link:

https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/424520

赞(0)
未经允许不得转载:TI中文支持网 » 【急,在线等!!!!】使用timer 设置PWM问题
分享到: 更多 (0)