manoj soorya
Member
Hi all...
I have a Voltmeter with PIC16F676...with source code too... its working good. I need to change the PINOUT of the IC to the display. This is a part of the original code.
and I changed this like...
compilation is okey.. but the second code doesnot work ....... any help would be appriciated...
Thank you
I have a Voltmeter with PIC16F676...with source code too... its working good. I need to change the PINOUT of the IC to the display. This is a part of the original code.
Code:
void io_init()
{TRISA = 0b00001001; // Ïîðò RA0 - âõîä
PORTA = 0b00000100;
TRISC = 0b00000000;
PORTC = 0b00001010;
ADCON0 = 0b00000001; // Êîíôèãóðèðóåì AN0 êàê àíàëîãîâûé
ADCON1 = 0b10000101; // 1110 D D D D D D D A VDD VSS 1/0
CMCON = 7;} // Âûêëþ÷àåì êîìïàðàòîð
void Dig_init()
{Dig[0] = 255-(a+b+c+d+e+f); // Åñëè èíäèêàòîð ñ îáùèì àíîäîì,
Dig[1] = 255-(b+c); // íóæíî ñóììó ìàêðîñîâ îòíÿòü îò
Dig[2] = 255-(a+b+g+e+d); // 255. Åñëè ñ îáùèì êàòîäîì, òî
Dig[3] = 255-(a+b+g+c+d); // îòíèìàòü íå íóæíî.
Dig[4] = 255-(f+g+b+c); // Èìåíà ìàêðîñîâ ñîîòâåòñòâóþò
Dig[5] = 255-(a+f+g+c+d); // èìåíàì ñåãìåíòîâ èíäèêàòîðà
Dig[6] = 255-(a+f+g+c+d+e); // Ïðèìåð:
Dig[7] = 255-(a+b+c); // Dig[7] = 255-(a+b+c);
Dig[8] = 255-(a+b+c+d+e+f+g);
Dig[9] = 255-(a+b+c+d+f+g);
Dig[10] = 255-0;}
void Display() { // Âûâîä íà äèñïëåé
RA = 0b00000000; // Èíäèêàòîðû ïîãàøåíû ðåæèì ÎÀ RA2, RC1, RC3 = 0
RC = 0b00000000; // Âñå ñòîëáöû K ðàâíû 1 Âñå ñåãìåíòû (a - h) ðàâíû 0
delay_Cyc(2);
if (ColCount >= 3) ColCount = 0; // åñëè ñ÷åò÷èê ñòîëáöîâ >= 3 îáíóëÿåì åãî
switch (ColCount) {
case 0 : RA.f2 = 1; break; // Âûáîð èíäèêàòîðà K1
case 1 : RC.f1 = 1; break; // Âûáîð èíäèêàòîðà K2
case 2 : RC.f3 = 1; } // Âûáîð èíäèêàòîðà K3
RC.f0 = Segment[ColCount].f0; //a
RC.f2 = Segment[ColCount].f1; //b
RA.f4 = Segment[ColCount].f2; //c
RA.f1 = Segment[ColCount].f3; //d
RA.f5 = Segment[ColCount].f4; //e
RC.f4 = Segment[ColCount].f5; //f
RC.f5 = Segment[ColCount].f6; //g
PORTA = RA; PORTC = RC;
ColCount++; }
and I changed this like...
Code:
switch (ColCount) {
case 0 : RA.f4 = 1; break; // Âûáîð èíäèêàòîðà K1
case 1 : RA.f1 = 1; break; // Âûáîð èíäèêàòîðà K2
case 2 : RA.f5 = 1; } // Âûáîð èíäèêàòîðà K3
RC.f2 = Segment[ColCount].f0; //a
RC.f3 = Segment[ColCount].f1; //b
RC.f4 = Segment[ColCount].f2; //c
RC.f5 = Segment[ColCount].f3; //d
RA.f4 = Segment[ColCount].f4; //e
RC.f1 = Segment[ColCount].f5; //f
RC.f0 = Segment[ColCount].f6; //g
compilation is okey.. but the second code doesnot work ....... any help would be appriciated...
Thank you
Last edited by a moderator: