⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opentimer45.c

📁 Mplab C30编译器
💻 C
字号:
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <timer.h>

/* These devices support Timers 4 and 5 */
#if defined(_TIMER4) && defined(_TIMER5)

/*******************************************************************************
Function Prototype : void OpenTimer45(unsigned int config,unsigned int period)
 
Include            : timer.h
 
Description        : This function configures the 32-bit timer module.
 
Arguments          : config - This contains the parameters to be configured in
                     the T4CON register as defined below
						Timer Module On/Off						
						   T45_ON						
						   T45_OFF						
						Timer Module Idle mode On/Off						
						   T45_IDLE_CON						
						   T45_IDLE_STOP						
						Timer Gate time accumulation enable						
						   T45_GATE_ON						
						   T45_GATE_OFF						
						Timer prescaler						
						   T45_PS_1_1						
						   T45_PS_1_8						
						   T45_PS_1_64						
						   T45_PS_1_256						
						Timer Synchronous clock enable						
						   T45_SYNC_EXT_ON						
						   T45_SYNC_EXT_OFF						
						Timer clock source						
						   T45_SOURCE_EXT						
						   T45_SOURCE_INT						
					  period - This contains the period match value to be stored 
					  into the PR register 
 
Return Value      : None
 
Remarks           : This function configures the 32-bit Timer Control register and 
                    sets the period match value into the PR register. 
**********************************************************************************/

void OpenTimer45(unsigned int  config,unsigned long period)
{
    TMR4 = 0;               /* Reset Timer4 to 0x0000 */
    TMR5 = 0;               /* Reset Timer5 to 0x0000 */
    PR4 = period;           /* assigning Period to Timer period register */
    PR5 = period>>16;       /* Period to PR4 and PR5 Register */
    T4CON = config;         /* configure timer control reg */
    T4CONbits.T32 = 1;
}

#else
#warning "Does not build on this target"
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -