ticlength.c
来自「8051试验程序 基础教材」· C语言 代码 · 共 54 行
C
54 行
//********************************************************************
//
// 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 <ioADuC842.h>
#define adcled P3_bit.P33
#define LED P3_bit.P34 //P3.4 drives red LED on eval board
#pragma vector=TII_int
__interrupt void TIC_int ()
{
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
IE_bit.EA = 1; // enable interrupts
PCON = 0x22; // enterpowerdown
while (1)
{
printf("96 Hour Have Elapsed\n");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?