zoukankan      html  css  js  c++  java
  • dsPIC33EP timer1 初始化设置及应用

    //文件 p33timer1.h
    
    #ifndef _P33TIMER1_H_
    #define _P33TIMER1_H_
    //#include "p33timer1.h"
    
    #define		TIMER1_IEN_ENB	_T1IE = 1
    #define		TIMER1_IEN_DIS	_T1IE = 0
    
    //timer1输入时钟分频
    #define		TIMER1_DIV1		(0<<4)
    #define		TIMER1_DIV8		(1<<4)
    #define		TIMER1_DIV64	(2<<4)
    #define		TIMER1_DIV256	(3<<4)
    
    
    //=========================================
    extern void Init_Timer1(uint16 T1div,uint16 Tcon) ;
    
    #endif
    
    
    
    //文件 p33timer1.c
    
    #include "global.h"
    #include "p33timer1.h"
    
    //***************************************
    // 函数名称:Init_Timer1
    // 函数功能:初始化timer1
    // 入口参数:时钟分频系数 定时器计数个数
    // 出口参数:无
    // 返回值:无
    // Timer1 的时钟源 = Fp(即外设时钟)
    //***************************************
    void Init_Timer1(uint16 T1div,uint16 Tcon)
    {
    	T1CON = 0X0000|T1div ;
    	PR1 = Tcon ; //重装载寄存器
    	TMR1 = 0x0000 ; //计数器
    	_T1IF = 0 ;
    	_T1IE = 0 ;
    	T1CON |= (1<<15) ; //开启定时器1	
    }
    
    //应用实例
    
    void main(void)
    {
    	
    	//外设时钟64分频到时钟 计数3599次 
    	Init_Timer1(TIMER1_DIV64,3599) ;// 
    	TIMER1_IEN_ENB ; //开启定时器中断
    //	TIMER1_IEN_DIS ;
    
    	while(1)
    	{
    
    	}
    	
    
    }


  • 相关阅读:
    使用Python创建自己的Instagram滤镜
    TensorFlow v2.0实现逻辑斯谛回归
    自动驾驶研究回顾:CVPR 2019摘要
    dp cf 20190613
    简单搜索 kuangbin C D
    树形dp compare E
    区间dp E
    Codeforces Round #564 (Div. 2)
    网络流 + 欧拉回路 = B
    网络流 A
  • 原文地址:https://www.cnblogs.com/suncoolcat/p/3397905.html
Copyright © 2011-2022 走看看