This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
你好!
问题描述:
我在Mini KeyFob例程里面的APP应用程序编写自己的代码,原来TI官网历程默认的Buzzer接到Timer3定时器的通道0 P1_6管脚,定时器工作在Up/down 模式,通道0采用的是输出比较模式Toggle output on compare (010) 这种模式来控制通道0产生PWM波形控制蜂鸣器播放一定的频率的响声的。
现在因为蜂鸣器的响声太小,所以改成蜂鸣器的两个管脚同时输出相反的PWM波形来控制蜂鸣器播放一定的频段,这样理论分析刚好响声能够增大一倍,我改成定时器Timer3的通道0和通道1管脚P1_6 P1_7,定时器工作在PWM模式,通道0的输出比较模式工作在Set output on compare-up, clear on compare-down in up-down mode (011),通道1的输出比较模式工作在Clear output on compare-up, set on compare-down in up-down mode (100),但是为什么产生的波形不对,P1_6通道0能产生波形,但是用示波器查看跟设置的频率不对,P1_7通道1用示波器观察不到波形,请指点!谢谢!
还有一个问题:在KeyFob工程里面的Buzzer.c文件里面的buzzerStart函数下面的代码是怎么实现的,我修改了Timer3的输出比较的工作模式,这段代码是不是还要修改下,谢谢!
// Get current Timer tick divisor setting
uint8 tickSpdDiv = (CLKCONSTA & 0x38)>>3;
// Check if frequency too low
if (frequency < (244 >> tickSpdDiv)){ // 244 Hz = 32MHz / 256 (8bit counter) / 4 (up/down counter and toggle on compare) / 128 (max timer prescaler)
buzzerStop(); // A lower tick speed will lower this number accordingly.
return 0;
}
// Calculate nr of ticks required to achieve target frequency
uint32 ticks = (8000000/frequency) >> tickSpdDiv; // 8000000 = 32M / 4;
// Fit this into an 8bit counter using the timer prescaler
while ((ticks & 0xFFFFFF00) != 0)
{
ticks >>= 1;
prescaler += 32;
}
能否详细解释下这段代码是怎么实现的,谢谢!
请指点下解决的办法,现在的问题是修改了Timer3的通道0和通道1的输出比较工作模式,用示波器抓看波形,频率跟设置的不对。