打印
[Kinetis]

KL05为什么这个程序经常复位?(已解决)

[复制链接]
918|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
keeryq|  楼主 | 2014-9-24 15:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 FSL_TICS_A 于 2014-10-8 09:44 编辑


#include "MKL05Z4.h"
int main(void)
{
        int tempCount,tempCount2 = 0;

        // clocking //
      
        for(tempCount = 0;tempCount<=200;tempCount++);
        for(tempCount = 0;tempCount<=200;tempCount++);
        for(tempCount = 0;tempCount<=200;tempCount++);
      
      
       // 外设时钟
        SIM_SOPT2 |= 0x01000000;      // clock sel for the timer0 // MCGFLLCLK
        SIM_SCGC5 |= 0x00000400;      // gating of clock // Port B Clock Gate Control
        SIM_SCGC6 |= 0x01000000;      // gating of timer //TOM0 Clock gate control
           
        TPM0_SC |= 0x00000004;        // every
        // port settings //
        PORTB_PCR8 |= 0x00000100;    // alternative pin mux selection // -- this 2 for PWM
        GPIOB_PDDR |= 0x00000100;    // pin direction // output

        //PORTB_PCR9 |= 0x00000200;
       // GPIOB_PDDR |= 0x00000200;
        //timer0//
        TPM0_CNT = 0;                // counter value. NOTE :- when debug is aactive this is not incremented !!!!!!!!! //
        TPM0_CNT = 0;                // counter value. NOTE :- when debug is aactive this is not incremented !!!!!!!!! //
        TPM0_CONF |= 192;            // counter runs in debug mode as well //
        TPM0_MOD = 0xFFFF;            // period count //    1309   
      
        TPM0_SC |= 0x00000008;
      
      
        while(1){            
                        if((TPM0_SC & 0x00000080) == 0x00000080){
                            GPIOB_PTOR |= (1<<8);
                            //Delay(20000);
                            //tempCount++;            
                            TPM0_SC |= TPM_SC_TOF_MASK; //write 1 to clear        
                           
                        }
                        else
                        {
                            tempCount2++;
                        }
                }      
}  


相关帖子

沙发
FSL_TICS_Robin| | 2014-9-25 09:28 | 只看该作者
楼主你好
请问你用的是否为飞思卡尔官网推出的KL05-SC例程包程序呢?

使用特权

评论回复
板凳
jd972594| | 2014-9-28 09:08 | 只看该作者
楼主把工程传上来让大家试试呗

使用特权

评论回复
地板
FSL_TICS_Robin| | 2014-9-30 09:23 | 只看该作者
楼主你好
我在PE创建的KL05程序上加入你的main函数,运行正常没有经常复位。
能否提供更多信息以便大家参与讨论呢?
比如:外部电路、芯片具体型号、在哪个例程上修改的等等

使用特权

评论回复
5
FSL_TICS_A| | 2014-10-8 09:44 | 只看该作者
楼主你好
请问此问题解决了吗,如果尚未解决欢迎继续讨论。
由于长时间未回帖,所以先把你的帖子标示成已解决了。
如果有空还请配合我们按照论坛置顶帖:本论坛中结帖方式 描述操作

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

14

主题

35

帖子

0

粉丝