金牌会员
- 积分
- 2669
- 威望
- 1377
- 贡献
- 668
- 兑换币
- 240
- 注册时间
- 2012-3-31
- 在线时间
- 312 小时
|
{
/* Make sure the clock to the LPTMR is enabled */
SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;
/* Set the compare value to the number of ms to delay */
LPTMR0_CMR = ms;
/* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;//选择时钟1KHZ,
/* Start the timer */
LPTMR0_CSR = LPTMR_CSR_TEN_MASK;
/* Wait for counter to reach compare value */
while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));
/* Clear Timer Compare Flag */
LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;
return;
}
我在main函数中加IO取反,加了一个1ms延时,为什么用示波器测出的频率是165HZ呢,不应该是500HZ吗,有没有试过的
|
|