智能车制作

标题: 火哥,调试问题求解 [打印本页]

作者: 15123as    时间: 2013-9-14 17:25
标题: 火哥,调试问题求解
我已经按照三天入门的教程做了一个工程,已经define了simulator,但是还是会卡死在while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));这句话中,怎么回事呢?
作者: 野火    时间: 2013-9-14 20:02
试下替换一下,用下面的函数:
  1. void time_delay_ms(uint32 ms)
  2. {
  3.     /* Make sure the clock to the LPTMR is enabled */
  4.     SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;

  5.     /* Set the compare value to the number of ms to delay */
  6.     LPTMR0_CMR = ms;

  7.     /* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
  8.     LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;

  9.     /* Start the timer */
  10.     LPTMR0_CSR = LPTMR_CSR_TEN_MASK;

  11.     /* Wait for counter to reach compare value */
  12.     while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));

  13.     /* Clear Timer Compare Flag */
  14.     LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

  15.     return;
  16. }
复制代码

作者: 野火    时间: 2013-9-14 20:04
试下替换一下,用下面的函数:
  1. void time_delay_ms(uint32 ms)
  2. {
  3.     /* Make sure the clock to the LPTMR is enabled */
  4.     SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;

  5.     /* Set the compare value to the number of ms to delay */
  6.     LPTMR0_CMR = ms;

  7.     /* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
  8.     LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;

  9.     /* Start the timer */
  10.     LPTMR0_CSR = LPTMR_CSR_TEN_MASK;

  11.     /* Wait for counter to reach compare value */
  12.     while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));

  13.     /* Clear Timer Compare Flag */
  14.     LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

  15.     return;
  16. }
复制代码

作者: 野火    时间: 2013-9-14 20:04
感觉你用的是比较旧的代码

作者: 15123as    时间: 2013-9-14 23:02
野火 发表于 2013-9-14 20:04
感觉你用的是比较旧的代码

谢谢,可以提供一下新代码的下载链接吗
作者: 野火    时间: 2013-9-15 00:11
15123as 发表于 2013-9-14 23:02
谢谢,可以提供一下新代码的下载链接吗

http://www.znczz.com/home.php?mod=space&uid=89016&do=blog&id=376
作者: 天马行空_8    时间: 2013-11-21 20:12
野火 发表于 2013-9-14 20:04
感觉你用的是比较旧的代码

我想用那个预分频怎么设置完了没法应啊  就改了这一个
// LPTMR0_PSR = LPTMR_PSR_PCS(1)|LPTMR_PSR_PBYP_MASK;
  LPTMR0_PSR = 0x78;






欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2