📄 timer1.h
字号:
#include "p30f2010.h"
#define FCY 29491200
// TCY=1/FCY = 33.9 ns
// 1ms 29491.2
// 5ms 1474456
//#define MIN_ENCODER_PER_PWM 6000
#define T1_ON 0xffff /* Timer1 ON */
#define T1_OFF 0x7fff /* Timer1 OFF */
#define T1_IDLE_CON 0xdfff /* operate during sleep */
#define T1_IDLE_STOP 0xffff /* stop operation during sleep */
#define T1_GATE_ON 0xffff /* Timer Gate time accumulation enabled */
#define T1_GATE_OFF 0xffbf /* Timer Gate time accumulation disabled */
#define T1_PS_1_1 0xffcf /* Prescaler 1:1 */
#define T1_PS_1_8 0xffdf /* 1:8 */
#define T1_PS_1_64 0xffef /* 1:64 */
#define T1_PS_1_256 0xffff /* 1:256 */
#define T1_SYNC_EXT_ON 0xffff /* Synch external clk input */
#define T1_SYNC_EXT_OFF 0xfffb /* Do not synch external clk input */
#define T1_SOURCE_EXT 0xffff /* External clock source */
#define T1_SOURCE_INT 0xfffd /* Internal clock source */
/* defines for Timer Interrupts */
#define T1_INT_PRIOR_7 0xffff /* 111 = Interrupt is priority 7 */
#define T1_INT_PRIOR_6 0xfffe /* 110 = Interrupt is priority 6 */
#define T1_INT_PRIOR_5 0xfffd /* 101 = Interrupt is priority 5 */
#define T1_INT_PRIOR_4 0xfffc /* 100 = Interrupt is priority 4 */
#define T1_INT_PRIOR_3 0xfffb /* 011 = Interrupt is priority 3 */
#define T1_INT_PRIOR_2 0xfffa /* 010 = Interrupt is priority 2 */
#define T1_INT_PRIOR_1 0xfff9 /* 001 = Interrupt is priority 1 */
#define T1_INT_PRIOR_0 0xfff8 /* 000 = Interrupt is priority 0 */
#define T1_INT_ON 0xffff /* Interrupt Enable */
#define T1_INT_OFF 0xfff7 /* Interrupt Disable */
/* Macros to Enable/Disable interrupts and set Interrupt priority of Timers 1*/
#define EnableIntT1 _T1IE = 1
#define DisableIntT1 _T1IE = 0
#define SetPriorityIntT1(priority) _T1IP = priority
/******************************************************************************************
This function first disables the 16-bit timer interrupt and then turns off the timer module.
The Interrupt Flag bit (TxIF) is also cleared.
*******************************************************************************************/
void CloseTimer1(void);
/*********************************************************************************************
This function clears the 16-bit Interrupt Flag (TxIF) bit and then sets the interrupt priority
and enables/disables the interrupt.
**********************************************************************************************/
void ConfigIntTimer1(unsigned int config);
/***********************************************************
This function configures the 16-bit Timer Control register
and sets the period match value into the PR register.
***********************************************************/
void OpenTimer1(unsigned int config,unsigned int period);
/************************************************************
This function returns the contents of the 16-bit TMR register
*************************************************************/
//unsigned int ReadTimer1(void);
/************************************************************
This function writes the 16-bit value into the Timer register.
*************************************************************/
//void WriteTimer1(unsigned int timer);
void timer1_init(void);
void __attribute__((__interrupt__,__no_auto_psv__ , __shadow__)) _T1Interrupt(void);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -