- This topic has 0 replies, 1 voice, and was last updated 8 years, 7 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
|
Microcontroller › PIC › Pic16f690 interfacing wih two 7 segment using 7447 delay using timer 0
Hi Everyone
i'm using PIC16f690 interface with two seven segment by 7447
im making 0 to 99 counter by using timer 0 of pic controller
i write a code but it shows only ''0'' on my both 7 segment…
can anybody please help me to figure out the problem
Thanks
#include <htc.h> // hi tech compiler for pic16
#define _XTAL _FREQ 4000000 // 4 Mhz freq
int overflow = 0; // counter variable for 0 to 99
void interrupt ISR(void) // timer interrupt
{
if(T0IF)
{
overflow++;
T0IF=0;
}
}
void timer0()
{
PSA = 0;
T0CS = 0;
PS1 =1; //prescaler 1:256
PS2 =1;
PS0 = 1;
T0IE = 1;
T0IF=0;
GIE = 1; // global interrupt enable
}
void main(void)
{
unsigned short second=0;
unsigned short x,y=0; // for display on segment
TRISC = 0;
TRISB7 = 1;
ANSEL = 0x00;
ANSELH = 0x00;
TMR0 = 0;
timer0(); //timer0 function
while (1)
{
if(overflow==15)
{
second++;
overflow = 0;
}
if(second>99)
{
second =0;
}
x = second/10;
y = second%10;
PORTC = (y<<4)+x; // PORTC connected with 7 segment via 7447
}
}