zoukankan      html  css  js  c++  java
  • PIC16F877A 看门狗定时器实验

    //*******************PIC16F877A 看门狗定时器实验*******************
    //
    //PORTA,PORTB,PORTC,PORTD,PORTE复位时为输入状态
    //PORTA.4(RA4)为开漏输出
    //
    //WDT运行于独立的内部RC振荡器,即使器件时钟停振,WDT仍正常工作
    //PIC16F877A单片机的WDT只能在烧写芯片时通过配置位启动或停止
    //WDT基本溢出时间为18ms,由于温度影响,该值在7-33ms之间变化
    //WDT和TMR0共用一个预分频器
    //PSA=1;           //预分频器分配给WDT使用
    //PS2  PS1  PS0     WDT
    // 0    0    0     1  分频
    // 0    0    1     2  分频
    // 0    1    0     4  分频
    // 0    1    1     8  分频
    // 1    0    0     16 分频
    // 1    0    1     32 分频
    // 1    1    0     64 分频
    // 1    1    1     128分频
    //
    //mcu: PIC16F877A  12MHz 
    //2010年7月11日8:03:01
    //****************************************************************

    #include <lian_pic.h>
    __CONFIG(HS&WDTEN&LVPDIS&PWRTEN);   
    //HS振荡,打开看门狗,低压编程关闭,启动延时定时器

    //********************函数定义*********************
    void delay1ms(uint DelayTime);

    //*************** 主程序 ********************
    void main(void)
    {   
        PSA=1;           //预分频器分配给WDT使用
        PS2=1;
        PS1=1;
        PS0=1;           //预分频器128分频
      TRISC=0x00;      //PORTC口设置为输出
      PORTC=0x00;
      CLRWDT();        //清看门狗

      while(1)        
      {
        PORTC++;
        delay1ms(200);
      }
    }   

    //***************延时 n*1ms 12MHz***************
    void delay1ms(uint DelayTime)
    {    uint temp;
        for(;DelayTime>0;DelayTime--)
        {    for(temp=0;temp<270;temp++)
            {;}
        }
    }

    //*******************PIC16F877A 看门狗定时器实验*******************
    //
    //PORTA,PORTB,PORTC,PORTD,PORTE复位时为输入状态
    //PORTA.4(RA4)为开漏输出
    //
    //WDT运行于独立的内部RC振荡器,即使器件时钟停振,WDT仍正常工作
    //PIC16F877A单片机的WDT只能在烧写芯片时通过配置位启动或停止
    //WDT基本溢出时间为18ms,由于温度影响,该值在7-33ms之间变化
    //WDT和TMR0共用一个预分频器
    //PSA=1;           //预分频器分配给WDT使用
    //PS2  PS1  PS0     WDT
    // 0    0    0     1  分频
    // 0    0    1     2  分频
    // 0    1    0     4  分频
    // 0    1    1     8  分频
    // 1    0    0     16 分频
    // 1    0    1     32 分频
    // 1    1    0     64 分频
    // 1    1    1     128分频
    //
    //mcu: PIC16F877A  12MHz  
    //2010年7月11日8:03:01
    //****************************************************************
    
    #include <lian_pic.h>
    __CONFIG(HS&WDTEN&LVPDIS&PWRTEN);	
    //HS振荡,打开看门狗,低压编程关闭,启动延时定时器
                    
    
    //********************函数定义*********************
    void delay1ms(uint DelayTime);
    
    
    //*************** 主程序 ********************
    void main(void)
    {	
    	PSA=1;           //预分频器分配给WDT使用
    	PS2=1;
    	PS1=1;
    	PS0=1;           //预分频器128分频
    	
      TRISC=0x00;      //PORTC口设置为输出
      PORTC=0x00; 
      
      CLRWDT();        //清看门狗
    
      while(1)         
      {
        PORTC++;
        delay1ms(200);
      } 
    }	
    
    //***************延时 n*1ms 12MHz***************
    void delay1ms(uint DelayTime)
    {	uint temp;
        for(;DelayTime>0;DelayTime--)
    	{	for(temp=0;temp<270;temp++)
    		{;}
    	}
    }
  • 相关阅读:
    Linux 下的类似Windows下Everything的搜索工具
    windows和linux环境下制作U盘启动盘
    程序调试手段之gdb, vxworks shell
    LeetCode 1021. Remove Outermost Parentheses (删除最外层的括号)
    LeetCode 1047. Remove All Adjacent Duplicates In String (删除字符串中的所有相邻重复项)
    LeetCode 844. Backspace String Compare (比较含退格的字符串)
    LeetCode 860. Lemonade Change (柠檬水找零)
    LeetCode 1221. Split a String in Balanced Strings (分割平衡字符串)
    LeetCode 1046. Last Stone Weight (最后一块石头的重量 )
    LeetCode 746. Min Cost Climbing Stairs (使用最小花费爬楼梯)
  • 原文地址:https://www.cnblogs.com/hnrainll/p/1919262.html
Copyright © 2011-2022 走看看