asking
Full Member level 5
- Joined
- Sep 21, 2010
- Messages
- 279
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- Activity points
- 3,377
Hello,
i m trying to build one counter circuit with 4 7-Segment multiplexing... my program is correct but still not properly working with proteus simulation...so guyz.. i need to calculate how to calculate refresh rate "Minimum Trigger" setting in 7 segment display properties....should i keep it default or some calculation is required ?
i have attached the image...i have kept 5ms refresh rate for display but still proteus is not showing proper...data..on display....please help...
MikroC Code:
i m trying to build one counter circuit with 4 7-Segment multiplexing... my program is correct but still not properly working with proteus simulation...so guyz.. i need to calculate how to calculate refresh rate "Minimum Trigger" setting in 7 segment display properties....should i keep it default or some calculation is required ?
i have attached the image...i have kept 5ms refresh rate for display but still proteus is not showing proper...data..on display....please help...
MikroC Code:
Code:
unsigned short i, DD0, DD1, DD2, DD3;
unsigned int Count;
//------ Function to Return mask for common anode 7-seg. display
unsigned short mask(unsigned short num) {
switch (num) {
case 0 : return 0x3F;
case 1 : return 0x06;
case 2 : return 0x5B;
case 3 : return 0x4F;
case 4 : return 0x66;
case 5 : return 0x6D;
case 6 : return 0x7D;
case 7 : return 0x07;
case 8 : return 0x7F;
case 9 : return 0x6F;
} //case end
}
void main() {
CMCON |= 7; // Disable Comparators
TRISB = 0x00; // Set PORTB direction to be output
PORTB = 0xff; // Turn OFF LEDs on PORTB
TRISA = 0b00100000; // RA5 is input only
Count = 0; // Initial Value of Counter
do {
DD0 = Count%10; // Extract Ones Digit
DD0 = mask(DD0);
DD1 = (Count/10)%10; // Extract Tens Digit
DD1 = mask(DD1);
DD2 = (Count/100)%10; // Extract Hundreds Digit
DD2 = mask(DD2);
DD3 = (Count/1000); // Extract Thousands Digit
DD3 = mask(DD3);
for (i = 0; i<=50; i++) {
PORTB = DD0;
RA0_bit = 0; // Select Ones Digit
RA1_bit = 1;
RA2_bit = 1;
RA3_bit = 1;
delay_ms(5);
PORTB = DD1;
RA0_bit = 1;
RA1_bit = 0; // Select Tens Digit
RA2_bit = 1;
RA3_bit = 1;
delay_ms(5);
PORTB = DD2;
RA0_bit = 1;
RA1_bit = 1;
RA2_bit = 0; // Select Hundreds Digit
RA3_bit = 1;
delay_ms(5);
PORTB = DD3;
RA0_bit = 1;
RA1_bit = 1;
RA2_bit = 1;
RA3_bit = 0; // Select Thousands Digit
delay_ms(5);
}
Count = Count + 1 ;
if (Count > 9999) Count = 0;
} while(1); // endless loop
}
Attachments
Last edited: