The crystal is a 12 Mhz //#include "F100GlobalDataTypeDefs.h" //#include "F100GlobalDef.h" //#include "F100GlobalVars.h" //#include "F100Functions.h" //#include "F100HW.h"
void msecWait(uint milliSeconds) { /* Since the counter counts up it is necessarey to subtract the nuber of counts/millsecnd from the maximum count for the sixteen bit unsigned intiger (65535 - 922 = 64613 = 0xFC65) seperated into bytes (uchar) hiByte = 0xFC and lowByte = 0x65 */ // uchar highByte = 0xfc, lowByte = 0x65; //922 counts/(milisecond up count) // count is from 64613 (0xfc65)
// bit bitET0, bitTR0;
/************ Based on 12 MHz crystal**** Input in miliseconds ***************
bitTR0 = TR0; // Save TR0 // TR0 = 0; // Stop T0 // bitET0 = ET0; // Save ET0 // ET0 = 0; // Disable T0 // while (milliSeconds > NOMILLISECONDS) { TH0 = highByte; TL0 = lowByte; TR0 = 1; //start timer 0 // while (!TF0) {;} TR0 = 0 ; // stop timer 0 // TF0 = 0 ; milliSeconds--; } ET0 = bitET0; // Restore ET0 // TR0 = bitTR0; // Restore TR0 // */ }