Why 'T2CONbits.TOUTPS =4;' instead of '9' to get 2.048 msec delay interrupt

Status
Not open for further replies.

saramah

Member level 3
Joined
Apr 25, 2018
Messages
64
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
689
hi.

It is a tutorilas where timer2 of pic16f887 with 20MHZ x-tal is being used with following settings and remarks by author,

Code:
   T2CONbits.TOUTPS =4;   //postsacler is /10 so 204.8us * 10 to 2.048 ms   

  T2CONbits.T2CKPS = 1;                                                                 
  TMR2=0x0;


With the above by author,

For the case of //T2CONbits.T2CKPS = 1; >>

FOSC/4(20/4=5MHZ ==0.2US), PS=1, ie., 1:4(datasheet), So, 0.2*4=0.8usec, as PR2 is FF on every reset

and then TMR2 and PR2 match>> at 0.8*256=204.8 usec. Till here this is OK.



But for //T2CONbits.TOUTPS =4; >>

Author stating thet delay 2.048 msec (=204.8*10)

My question is >>

Why 'TOUTPS =4' ???

Its coming at '9' instead of '4' (as datasheet say 1:10 for the value of '9') to get 2.048 msesc delay

Then only FLAG OF TMR2 AT (10*204.8)=2.048 msec.

May be I am missing some other things, could you help me out...

tnx..
 

Setting the TOUTPS value to 4 (0100 in binary) gives a division ratio of 1:5 not 1:10 so I think the author is wrong, the value should be 9 (1001 in binary).

Brian.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…