Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

am newer to the pic micro controller..

Status
Not open for further replies.

balaece

Newbie level 2
Joined
Sep 26, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,293
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..
 

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
.
.
.
 

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@gmail.com...thank you sir
 

Message is unavailable.
 

Selvabala

Ready PIC16f877a or 8051 Microcontroller by mohd ali mazidi. first u get the concept of TIMER and counter then go for programing.


u can get the code if u browse the net.. but understanding concept only u can perform well in doing.........


Srinu Hyderabad
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top