Rules | Recent posts | topic RSS | Search | Register  | Log in

am newer to the pic micro controller..

 
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Author Message
balaece



Joined: 26 Sep 2008
Posts: 2


Post29 Sep 2008 11:24   am newer to the pic micro controller..

i dont know how to use timer0 as a counter 0...can anybody help me to overcome this problem..i need the assembly code for counter0..thankyou..
Back to top
VVV



Joined: 26 Nov 2004
Posts: 1469
Helped: 270


Post29 Sep 2008 17:40   Re: am newer to the pic micro controller..

You just need to set up timer 0 to use the external clock and select the active edge (risig or falling). That means bit T0CS in the OPTION register must be set to 1 and bit T0SE of the same register will be set or clear dpending on what edge you need.
Generally you would not use a prescaler when you use the timer as a counter. So make sure bit PSA in the OPTION register is set to 1.

So it all boils down to writing the appropriate value to the OPTION register in order to use TMR0 as a counter.

Once you have done that, you can just read the TMR0 register in the normal fashion, using the movf TMR0,W instruction to see how many counts have accumulated. That's all there is to it.

For example, let's assume that you would not have the pullups enabled, you use a rising edge interrupt (or you don't care), you need rising edge on TMR0 input and the prescaler will be assigned to the WDT with a rate of 1:64. This is what you would do:

Code:

movlw B'11101110'  ; no pullups on RB, ext interrupt on rising edge, TMR0 uses ext clock, increments on rising edge,                   
                   ; WDT prescaler 1:64
movwf OPTION_REG   ;set up option register with the above; TMR0 counts ext pulses
.
.
.
movf TMR0,W        ;read TMR0 contents and use
.
.
.
Back to top
balaece



Joined: 26 Sep 2008
Posts: 2


Post06 Oct 2008 9:48   Re: am newer to the pic micro controller..

thank you sir...can you give some idea about comparator..and other modules in pic 16f877a...i am newer sir..if you can,you can send answer to my selvabala.ece(at)gmail.com...thank you sir
Back to top
MAK-1



Joined: 26 Jun 2008
Posts: 51
Helped: 3


Post07 Oct 2008 8:48   am newer to the pic micro controller..

http://www.edaboard.com/ftopic329731.html
Back to top
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers
Page 1 of 1 All times are GMT + 1 Hour


Abuse
Administrator
Moderators
topic RSS 
sitemap