I used the following proteus design and Mikro c code to build a 6 digit 7segment count down timer using pic16f887A and ic 4026
The proteus design is named Zacch in the attached file and the mikro c is in the code tag. the issue am having is that my proteus simulation isn't working as it supposed to. Can anyone pls help me trouble shoot the code. It is urgent
The proteus design is named Zacch in the attached file and the mikro c is in the code tag. the issue am having is that my proteus simulation isn't working as it supposed to. Can anyone pls help me trouble shoot the code. It is urgent
C:
int i = 0;
int j = 0;
int var = 0;
int var1 = 0;
int var2 = 0;
int var3 = 0;
int var4 = 0;
int secR = 0;
int secL = 0;
int MinL = 0;
int MinR = 0;
int X = 0;
int a = 0;
int b = 0;
int k = 0;
int m = 0;
int n = 0;
int Setup = 1;
int Stop = 0;
int e=0;
int h=0;
void all_rst()
{
PORTD.F0=1;
PORTD.F1=1;
PORTD.F2=1;
PORTD.F3=1;
PORTD.F4=1;
PORTD.F5=1;
PORTD.F0=0;
PORTD.F1=0;
PORTD.F2=0;
PORTD.F3=0;
PORTD.F4=0;
PORTD.F5=0;
}
void Display_Test()
{
all_rst();
var = 10;
for (j = 0; j < 10; j++)
{
var = var - 1;
for (i = 0; i < var; i++)
{
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=1;
PORTB.F3=1;
PORTB.F4=1;
PORTB.F5=1;
PORTB.F0=0;
PORTB.F1=0;
PORTB.F2=0;
PORTB.F3=0;
PORTB.F4=0;
PORTB.F5=0;
}
}
}
void c_inc()
{
X=1 ;
X=0 ;
}
void buzz()
{
for (e = 0; e < 10; e++)
{
PORTA.F2=1;
delay_ms(100);
PORTA.F2=0;
delay_ms(100);
}
}
void main() {
TRISA=0b11111111;
TRISB=0b00000000;
TRISC=0b00000000;
TRISD=0b00000000;
all_rst();
PORTC.F0=1;
PORTC.F1=1;
PORTC.F2=1;
PORTC.F3=1;
PORTC.F4=1;
PORTC.F5=1;
delay_ms(500);
Display_Test();
while(1) {
if (Setup==1)
{
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=0;
PORTC.F3=0;
PORTC.F4=0;
PORTC.F5=1;
while (PORTA.F1 != 0)
{
if (PORTA.F0 == 0)
{
X = PORTB.F5;
secR = secR + 1;
c_inc();
delay_ms(250);
if (secR > 9)
{
secR = 0;
}
}
}
delay_ms(250);
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=0;
PORTC.F3=0;
PORTC.F4=1;
PORTC.F5=0;
while (PORTA.F1 != 0)
{
if (PORTA.F0 == 0)
{
X = PORTB.F4;
secL = secL + 1;
c_inc();
if (secL > 5)
{
secL = 0;
PORTD.F4=1;
PORTD.F4=0;
}
delay_ms(250);
}
}
delay_ms(250);
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=0;
PORTC.F3=1;
PORTC.F4=0;
PORTC.F5=0;
while (PORTA.F1 != 0)
{
if (PORTA.F0 == 0)
{
X = PORTB.F3;
MinR = MinR + 1;
c_inc();
delay_ms(250);
if (MinR > 9)
{
MinR = 0;
}
}
}
delay_ms(250);
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=1;
PORTC.F3=0;
PORTC.F4=0;
PORTC.F5=0;
while (PORTA.F1 != 0)
{
if (PORTA.F0 == 0)
{
X = PORTB.F2;
MinL = MinL + 1;
c_inc();
delay_ms(250);
if (MinL > 9)
{
MinL = 0;
}
}
}
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=0;
PORTC.F3=1;
PORTC.F4=1;
PORTC.F5=1;
var1 = secR;
var2 = secL;
var3 = MinR;
var4 = MinL;
Setup = 0;
}
var1 = var1 - 1;
if (var1 == -1 && var2 == 0 && Stop == 0)
{
var1 = 9;
var2 = 5;
var3 = var3 - 1;
}
if (var1 == -1 && Stop == 0)
{
var2 = var2 - 1;
var1 = 9;
}
if (var3 == -1)
{
var3 = 9;
var4 = var4 - 1;
}
if (var1 == 9 && var2 == 5 && var3 == 9 && var4 == -1)
{
Stop = 1;
buzz();
}
while(stop)
{
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=0;
PORTC.F3=0;
PORTC.F4=0;
PORTC.F5=0;
delay_ms(300);
PORTC.F0=0;
PORTC.F1=0;
PORTC.F2=1;
PORTC.F3=1;
PORTC.F4=1;
PORTC.F5=1;
delay_ms(300);
}
delay_ms(1000);
PORTD.F5=1;
PORTD.F5=0;
for (a = 0; a < var1; a++)
{
PORTB.F5=1;
PORTB.F5=0;
}
PORTD.F4=1;
PORTD.F4=0;
for (b = 0; b < var2; b++)
{
PORTB.F4=1;
PORTB.F4=0;
}
PORTD.F3=1;
PORTD.F3=0;
for (h = 0; h < var3; h++)
{
PORTB.F3=1;
PORTB.F3=0;
}
PORTD.F2=1;
PORTD.F2=0;
for (k = 0; k < var4; k++)
{
PORTB.F2=1;
PORTB.F2=0;
}
}
}
Last edited: