最近想用CC2541做个单芯片控制超声波的项目,请问一下TI的员工们,CC2541的PWM最高能到多少Hz?有没有例程?
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.
按这个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;
}