ticlength.c

来自「Example codes for ADuC842 CPU family」· C语言 代码 · 共 52 行

C
52
字号
//********************************************************************
//
// Author        : ADI - Apps            www.analog.com/MicroConverter
//
// Date          : October 2003
//
// File          : ticlength.c
//
// Hardware      : ADuC842/ADuC843
//
// Description   : Demonstrates the use of the Time Interval Counter to
//					count an interval of 96 hours		
//					A message is displayed constantly on the hyperterminal window
//					after the time has elapsed.
//					Note: This code can be chaged to 96second period by
//					setting Timecon=0x01B; to show its use 	
//********************************************************************

#include <stdio.h> 
#include <ADuC842.h>

sbit LED = 0x0B4;

void TIC_int () interrupt 10
{
	TIMECON=0x00;
	LED ^= 1;
}

void main (void)
{
						//Configure the baud rate 9600
	T3CON = 0x83;
	T3FD  = 0x2D;
	SCON  = 0x52;

						//Configure Time Interval Counter  
	TIMECON = 0x3B; 	// configure the Time Interval Counter to count a single period in hours
					  	//set to 0x01B to time 96 seconds
	INTVAL = 0x60;   	// 96 hours

						//Configure External Interrupt
	IEIP2 = 0xA4;   	// enable TIC interrupt
   	EA = 1;				// enable interrupts

	PCON = 0x22;		// enterpowerdown
	while (1)
	{
	printf("96 Hour Have Elapsed\n");
	}
}

⌨️ 快捷键说明

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