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