最近想用CC2541做个单芯片控制超声波的项目,请问一下TI的员工们,CC2541的PWM最高能到多少Hz?有没有例程?
Viki Shi:
例程可参考协议栈里的KeyFobDemo,路径:C:\Texas Instruments\BLE-CC254x-1.5.0.16\Projects\ble\KeyFob\Source。里面的buzzer.c用timer生成PWM
TOWN WEN:
回复 Viki Shi:
按这个BUZZER的程序,我的frequency能达到100K吗?
uint8 buzzerStart(uint16 frequency)
{
#if defined ( CC2540_MINIDK )
buzzerInit();
uint8 prescaler = 0;
// 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;
}
// Update registers
T3CTL &= ~0xE0;
T3CTL |= prescaler;
T3CC0 = (uint8)ticks;
// Start timer
T3CTL |= 0x10;
#endif
return 1;
}
YiKai Chen:
回复 TOWN WEN:
100K應該不是問題、PWM可以參考一下sunmaysky.blogspot.com/…/how-to-output-pwm-from-cc2530.html
TOWN WEN:
回复 YiKai Chen:
你的这个链接打不开。
YiKai Chen:
回复 TOWN WEN:
被防火牆擋住了吧
TOWN WEN:
回复 YiKai Chen:
估计是government forbidden了。可否把内容贴到这里来?
YiKai Chen:
回复 TOWN WEN:
試試VPN吧
TOWN WEN:
回复 YiKai Chen:
为看个帖子去买个VPN,我太难了。
还有别的链接可以推荐吗?