Timer0 PIC16F917 | Microcontroller › PIC › Timer0 PIC16F917 This topic has 0 replies, 1 voice, and was last updated 11 years, 8 months ago by Dragu Mircea. Viewing 1 post (of 1 total) Author Posts December 29, 2012 at 8:32 pm #3909 Dragu MirceaParticipant Hy.I am a beginner in programming microcontroller. I use PIC16F917 microcontroller.I made a program who must realize the next tasks : – Led D0 stay ON 3 second – Led D0 goes OFF and remain in these state 3 second. My program : #include<pic.h> int count = 0; int main() { TRISD = 0b01111111; // RD7 – output TMR0 = 0; // Timer register is reset T0CS = 0; // Work with internal CLK T0SE = 0; // Reacting on Low to High edge PSA = 0; // Work with a prescaler PS0 = 1; PS1 = 1; PS2 = 1; // Prescaler value divides in 256 while(1) { PORTDbits.RD7 = 1; // D7 pin is ON while(!T0IF); // Stays here 256 times and then T0IF=1 T0IF = 0; // Reseting the overflow flag count++; // Increasing by 1 if(count == 46) { count = 0; // When count reaches 46 – reseting to 0 } PORTDbits.RD7 = 0; while(!T0IF); T0IF = 0; count++; if(count == 46) { count = 0; } } } Thank you. With respect Mircea. Author Posts Viewing 1 post (of 1 total) You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In