查看: 1801|回复: 2

[已解决] KL16的LPTMR无法使用问题(已解决)

[复制链接]

该用户从未签到

4

主题

11

帖子

0

新手上路

Rank: 1

积分
46
最后登录
1970-1-1
发表于 2014-10-11 10:25:13 | 显示全部楼层 |阅读模式
本帖最后由 FSL_TICS_ZP 于 2014-10-11 17:06 编辑

isr.H内定义了:extern void lptmr_isr(void);

#undef  VECTOR_044
#define VECTOR_044 lptmr_isr




uint32 lptmr_incr;
void lptmr_isr(void)
{
lptmr_incr++;
  LPTMR0_CSR |=  LPTMR_CSR_TCF_MASK;   // write 1 to TCF to clear the LPT timer compare flag
}



初始化:
void lptmr_init(int count, int clock_source)
{
    SIM_SCGC5 |= SIM_SCGC5_LPTMR_MASK;
    LPTMR0_PSR = ( LPTMR_PSR_PRESCALE(0) // 0000 is div 2
                 | LPTMR_PSR_PBYP_MASK  // LPO feeds directly to LPT
                 | LPTMR_PSR_PCS(clock_source)) ; // use the choice of clock
    if (clock_source== 0)
      printf("\n LPTMR Clock source is the MCGIRCLK \n\r");
    if (clock_source== 1)
      printf("\n LPTMR Clock source is the LPOCLK \n\r");
    if (clock_source== 2)
      printf("\n LPTMR Clock source is the ERCLK32 \n\r");
    if (clock_source== 3)
      printf("\n LPTMR Clock source is the OSCERCLK \n\r");

    LPTMR0_CMR = LPTMR_CMR_COMPARE(count);  //Set compare value

    LPTMR0_CSR =(  LPTMR_CSR_TCF_MASK   // Clear any pending interrupt
                 | LPTMR_CSR_TIE_MASK   // LPT interrupt enabled
                 | LPTMR_CSR_TPS(0)     //TMR pin select
                 |!LPTMR_CSR_TPP_MASK   //TMR Pin polarity
                 |!LPTMR_CSR_TFC_MASK   // Timer Free running counter is reset whenever TMR counter equals compare
                 |!LPTMR_CSR_TMS_MASK   //LPTMR0 as Timer
                );
    LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;   //Turn on LPT and start counting
    enable_irq(28);
}





主程序:
main()
{
    lptmr_init(1000, LPTMR_USE_LPOCLK);
    while(1);


}


然后,串口会连续不断的输出:
****default_isr entered on vector 4194348*****
有时候是连续不断输出:
****default_isr entered on vector 44*****
不知道为什么。
就算我的中断服务程序没配置对,也应该是间隔1秒了输出,但实际上是连续不断的输出。求解???

我知道答案 目前已有2人回答
回复

使用道具 举报

该用户从未签到

4

主题

11

帖子

0

新手上路

Rank: 1

积分
46
最后登录
1970-1-1
 楼主| 发表于 2014-10-11 14:40:57 | 显示全部楼层
已经解决,编译器需要clean 中间件
回复 支持 反对

使用道具 举报

该用户从未签到

124

主题

3600

帖子

0

金牌会员

Rank: 6Rank: 6

积分
5781
最后登录
1970-1-1
发表于 2014-10-11 17:05:50 | 显示全部楼层
你好,楼主!
由于KL25和KL16都是L系列的,很多东西都是一样,只是部分外围模块,Flash,ram大小之别,所以完全可以参考KL25的LPTMR的例程。
请参考此贴的LPTMR中断例程创建过程,链接如下:
https://www.nxpic.org.cn/module/ ... =page%3D&page=6
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /3 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2025-9-8 03:50 , Processed in 0.078456 second(s), 23 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表