Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

I need your help please

Status
Not open for further replies.

Alibataineh

New Member
Hello everyone,
Hope you're doing well .
I study power engineering and this is my third year. To be able to graduate I have to pass micro-controller course, even though it's not related to my field of study.
Anyway, I was searching online and I'm really thrilled to find this site.
I need your help regarding programming TMR0 as counter. Does anyone know how to write a program to count the number of negative pulses received on one of the PIC 6F877 I/O pins ?
Thank you in advanced,
You'd really save my life if you know the code
Peace
 
Someone told me this would help me to actually count the positive pulses :

main:

; 1. configure tmr0

movlw b’10111000’
movwf option_reg

; 2. Set up ports
movlw 0x00 ;
Movwf trisd
movlw B’00011111’ ;
Movwf trisa ;

; 3. Mask 2nd digit of TMR0

loop:movf trm0,w ;
Andlw 0x0f;
call segment
movwf portd ;
goto loop ;



Is that true :) ? What about the negative pulses ?
 
All you do is change the option register bit 4 to 0
I don't want you to think I'm be smart but there a pdf called the 16F877 datasheet if you look at timer0
It tells you what setting to use and how to use it.

I read the datasheet even if I think I no the setting I still read it, You'll learn a lot from it trust me on that one.

Code:
; 1. configure tmr0
    ; movlw b’10111000’        ; this setting is low to high
     movlw b’10101000’         ; you change bit 4  this reads high to low 
     movwf option_reg

; 2. Set up ports
     movlw 0x00 ;
     Movwf trisd
     movlw B’00011111’ ;
     Movwf trisa ;

; 3. Mask 2nd digit of TMR0

     loop:movf trm0,w ;
     Andlw 0x0f;
     call segment
     movwf portd ;
     goto loop ;

This is really good it's in C but it tells how the timer0 works https://www.electro-tech-online.com/custompdfs/2012/12/51682A.pdf

And this is real good about timer0 in asm https://www.electro-tech-online.com/custompdfs/2012/12/PIC_Mid_A_4.pdf
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top