juturu praneeth

DT512 timer-delay calculation

Discussion created by juturu praneeth on Mar 12, 2009
Latest reply on Mar 13, 2009 by kef

I want to know whether i am correct in calculating the delay value...

 

My program goes this way

TSCR1=0x90//timer enable,fast clear flag enable.

TIOS_IOS0=1;

TSCR2=0x07;//PRESCALAR=128

TCTL2=0x01;

TFLG1_C0F=1;

 

TC0=0x124F;//  FOR 300ms DELAY.....

 while(!TFLG1_C0F);//waiting for timer to complete......

CALCULATION

count*time period = delay

=> count=300ms/timeperiod

            =300ms/(128/2MHz)

            =0x124f

 

Should i load 0x124f to TC0 or should i load (oxffff-0x124f) into TC0 to obtain 300millisecond delay...

Outcomes