//====================================================================
//
// Author : ADI - Apps
//
// Date : 17 October 2003
//
// File : Tim2_AR.c
//
// Hardware : ADuC845
//
// Description : Flashes LED on P3.4 every approx 20Hz
//____________________________________________________________________
#include <stdio.h>
#include <ADuC845.h>
sbit half_or_full = P0^0;
sbit L297_clock = P0^1;
sbit direction = P0^2;
sbit L297_enable = P0^3;
void interrupt_0 () interrupt 1
{
TL0 = 0xf0;
TH0 = 0xfb;
TF0 = 0;
L297_clock=L297_clock^1;
}
void TIC_int () interrupt 10
{
direction=direction^1;
}
void delay(int length)
{
while (length >=0)
length--;
}
void main (void)
{
ET0 = 1;
TMOD = 0x01;
TL0 = 0xf0;
TH0 = 0xfb;
EA = 1;
TR0 = 1;
IEIP2 = 0x04; //Enable TIC interrupt
EA = 1; //Enable global interrupts
TIMECON = 0xD0; //Count in seconds
INTVAL = 0x05; //Count duration (5 second delay between temperature readings)
delay(10000); //Delay to allow TIC registers be written
//Since TIC operates from 32.768kHz time must be given
//to ensure the TIC registers are written to correctly.
TIMECON = 0xD3; //Start counting, enable INTVAL counter & TIC counter
half_or_full=0;
direction=0;
L297_enable=1;
while(1);
}