#include "hcs12.h"#include "DBug12.h"#include "vectors12.h"#include "delay.c"main( ){ unsigned int time, first, second, frequency, total; TSCR1 = 0x80; //Bit 7 = 1 ; turns on timer sub system TSCR2 = 0x03; //Overflow time //Sets up IOC1 TIOS =0x00; //Enables IOC1 TCTL4 = 0x14; //Selects edge to capture TFLG1 = 0x02; //Sets up IOC2 TIOS = 0x00; //Enables IOC2 TCTL4 = 0x14; //Selects edge to capture TFLG1 = 0x04; while(( TFLG1 & 0x02) == 0); //waits for 1st rising edge first = TC1; //Reads time of 1st edge while(( TFLG1 & 0x04) == 0); //waits for second rising edge second = TC2; //Reads time of 2nd edge. total = second - first; frequency = 1/total; DB12FNP->printf("TC1 = %d \n \n",first); DB12FNP->printf("TC2 = %d \n \n",second); DB12FNP->printf("total = %d \n \n",total); DB12FNP->printf("frequency = %d \n", frequency); return 0; }
Message Edited by gda02 on 2007-05-0207:20 AM