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

📄 timer.c

📁 ucos-II2.51在S3C44B0X上的移植 开发环境:SDT2.50 实验板:ES44BO
💻 C
字号:
/*
 *************************************************************************
 * Copyright (c) 2003, The Lab of Embedded System and Net Security,WHUT..
 * All rights reserved. 
 *
 * Filename:    timer.c
 * Discription: This file deals with timers in s3c44b0
 * 
 * version:            1.0
 * Author:             Qiu Yanfei <qyfhm@tom.com>
 * Accomplished Date:  2004/7/25 11:29:00
 *************************************************************************
*/
#include "..\cpu\44breg.h"
#include "..\interrupt\interrupt.h"
#include "D:\uCOS-II_PORT\OS_CPU\os_cpu.h"
#include "timer.h"
#include "..\cpu\44breg.h"

/*
 *********************************************************************
 * Initialize timer that is used OS.
 * clock input frequency = MCLK / (prescaler value + 1) / (divider value)
 * one tick time = (prescaler value + 1)*(divider value)*(rTCNTB0-rTCMPB0)/MCLK
 * T0 = 1*2*64000/64M = 2ms tick for OS; 
 *********************************************************************
*/
void timer_init(void)
{
        rTCFG0 = 31;            	// prescaler0 = 31
	rTCFG1 = 0x0;              // mux0 = 1/2   	   
	rTCNTB0 = 20000; 	         //fin=MCLK/(31+1)/2=1MHz  T=(1/1MHz)*20000=20ms
	rTCMPB0 = 0x0;
	rTCON = 0x6;		//update mode for TCNTB0 and TCMPB0.	
	rTCON = 0x9;		//timer0 = auto reload, start
	

}

void InstallSystemTimer(void)
{
	 
    rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL);	//Default value=0x7ffffff
}


 
/*
 *********************************************************************
 * start watchdog
 * clock input frequency = MCLK / (prescaler value + 1) / (divider value)
 * reset time = (prescaler value + 1)*(divider value)*rWTCNT/MCLK
 * eg. reset time = (64*128*0xffff)/64000000 = 8,388,480 us
 *********************************************************************
*/
void watchdog_start(void)
{
    rWTCON = ((64-1)<<8)|(3<<3)|(1);  //1/48/128, reset enable 48M    
    rWTDAT = 0xffff;
    rWTCNT = 0xffff;     
    rWTCON |= (1<<5);           //start watchdog 
}

U32 watchdog_stop(void)
{
    rWTCON=((64-1)<<8);
    return (0xffff-rWTCNT);
}

⌨️ 快捷键说明

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