📄 system_time.c
字号:
//========================================================================
// The information contained herein is the exclusive property of
// Sunplus Technology Co. And shall not be distributed, reproduced,
// or disclosed in whole in part without prior written permission.
// (C) COPYRIGHT 2001 SUNPLUS TECHNOLOGY CO.
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorized copies.
//========================================================================
//========================================================================
// Filename: System_time.c
// Author: Lianshu Mou (email: Lianshu@sunnorth.com.cn)
// Date: 2004/08/05
// Description:
//
// Reference:
// Revision:
// 2004/08/05 First version
//========================================================================
#include "Spmc75_regs.h"
#include "mcMACRO.h"
#define Time_1mS 0x5dc0
//=================================================================================================
// Description: IRQ3 interrupt source is XXX,used to XXX
// Notes:
//=================================================================================================
int g_iWork_Daly_Time = 0; //系统定时计数器
int g_iMoto_Run_Time = 0;
int g_iADC_Work_Time = 0;
void IRQ4(void) __attribute__ ((ISR));
void IRQ4(void)
{
if(P_TMR2_Status->B.TPRIF)
{
P_TMR2_Status->B.TPRIF = 1;
g_iWork_Daly_Time ++; //定时计数器加1
g_iMoto_Run_Time ++;
g_iADC_Work_Time ++;
}
}
//=================================================================================================
// ----Function: void Systime_Init(void);
// -Description: TMR2_module initialize function
// --Parameters: None
// -----Returns: None
// -------Notes:
//=================================================================================================
void Systime_Init(void)
{
P_TMR2_Ctrl->B.MODE = CB_TMR2_MODE_Normal; //P_TMR2_Ctrl Init
P_TMR2_Ctrl->B.CCLS = CB_TMR2_CCLS_TPR;
P_TMR2_Ctrl->B.CKEGS = CB_TMR2_CKEGS_Rising;
P_TMR2_Ctrl->B.TMRPS = CB_TMR2_TMRPS_FCKdiv1;
P_TMR2_TPR->W = Time_1mS;
P_TMR2_INT->B.TPRIE = CB_TMR2_TPRIE_Enable; //Timer Period interrupt Enable
P_TMR_Start->B.TMR2ST = CB_TMR_TMR2ST_Start; //Timer 2 RUN
}
//=================================================================================================
// ----Function: void Work_daly(int Time);
// -Description: System daly Time
// --Parameters: None
// -----Returns: None
// -------Notes:
//=================================================================================================
void Work_daly(int Time)
{
g_iWork_Daly_Time = 0;
while(g_iWork_Daly_Time < Time);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -