thir13enth
Member level 1
- Joined
- Feb 23, 2011
- Messages
- 38
- Helped
- 4
- Reputation
- 8
- Reaction score
- 4
- Trophy points
- 1,288
- Location
- Quezon City, Philippines
- Activity points
- 1,545
Microcontroller = PIC16F877A
Oscillator = 20MHz XT
Compiler = MikroC
----------------------------
Hello, I am trying to work my Timer 0 with my PIC. Unfortunately, I cannot make it work the way I wanted it to. There is no error when I compile my program, but when I try to simulate it in Proteus, it gave fast outputs. Here is my code:
What I need is to lengthen its duration. Say for example, 2 seconds. Anyone who has a tutorial on how to do do the calculations especially the preload value? I want to learn how, of course based with my PIC which is PIC16F877A.
Regards,
Gello Mark C. Vito
Oscillator = 20MHz XT
Compiler = MikroC
----------------------------
Hello, I am trying to work my Timer 0 with my PIC. Unfortunately, I cannot make it work the way I wanted it to. There is no error when I compile my program, but when I try to simulate it in Proteus, it gave fast outputs. Here is my code:
Code:
unsigned count;
void main() {
OPTION_REG = 0xE4; // gie = peie = tmr0ie = tmr0if = 1
TRISD = 0x00;
PORTD = 0x00;
TMR0 = 0;
INTCON = 0x07; // PS0 = PS1 = PS2 = 1 set to 1:256
do {
count++;
if (count == 76) {
PORTD = ~PORTD; // Toggle PORTB LEDs
count = 0; // Reset cnt
}
} while(1);
}
What I need is to lengthen its duration. Say for example, 2 seconds. Anyone who has a tutorial on how to do do the calculations especially the preload value? I want to learn how, of course based with my PIC which is PIC16F877A.
Regards,
Gello Mark C. Vito