Hi I have been going through example and I am struck on one thing.... Need to generate 250mS So I look at the table, the fastest rate which allws timer T3 to have a period of 250mS is 156.25 kHz hence T31= 100b 250mS/420 = 59.52 where 420mS is the maximum period. The intial value of the timer register is 39009 (65535*0.595)... I am still baffled with value of T3_RELOAD=100 so can someone kindly tell where 100 come from? Thank you
#include <reg167.h> #define T3_RELOAD 39009 /* T3 reload value : 250 ms */ //#define T3_RELOAD 100 /* T3 reload value : 250 ms */ /* Timer T3 ISR */ void T3_elapsed(void) interrupt 0x23 { T3 = T3_RELOAD; /* reset T3 */ P2 ^= 0x0001; /* toggle P2.1 */ } /* main program */ void main(void) { DP2 |= 0x0001; /* P2.1 : output */ P2 |= 0x0001; /* initially: LED off */ T3 = T3_RELOAD; /* load initial timer value T3 */ /* T3 in timer mode, counting down, pre-scale factor 128, period: 420 ms */ /* alternate output function disabled */ /* T3CON = 0000.0000.1000.0100 = 0x0084 */ T3CON = 0x0084; T3IC = 0x0044; /* enable T3 interrupt, ILVL = 1, GLVL = 0 */ IEN = 1; /* allow all interrupts to happen */ T3R = 1; /* start timer (T3CON |= 0x0040) */ while(1); /* forever... */ } /* main */