|
Four digit display could be used for a clock. Four BCD digits are translated to seven segement output. Seven segments are wired with bit0-7 attached to segment A-G and decimal point to Bit7
Conclusion: It can be done 2 millisecond seem about the best time for display not to flicker. But output of display driven direct from pic is dim due to week sink/source current of output ports.
************* CPU = 16F876 MHZ = 20 CONFIG 16382
;Basically there are 3 parts to this program
;1) the BCD portion ;2) the translation lookup table ;3) the multiplex display
;display digits donothing var byte counter var word temp1 var byte temp2 var byte digits var nib(4)
;Seven segment display bytes
segment var byte(4) TrisA=$00 TrisB=$00 ;outputs lower nib trisC=$00 ;outputs CLEAR
main: if donothing=0 then counter=counter+1 endif
donothing=donothing+1; Waste some time to see if display can keep up
gosub multiplex
goto main
multiplex: ;Common anode output of 4 digits lookup table would be opposite for common cathode. for temp1=0 to 3 digits(temp1)=counter.nib(temp1) ;lookup seven segment output, load into output byte lookup digits(temp1), [%11000000,%11111001,%10100100,%10110000,%10011001,%10010010,%10000010,%11111000,%10000000,%10011000,%10001000,%10000011,%10100111,%10100001,%10000100,%10001110],segment(temp1) next
portC=segment(0);set output of LSB portA.bit0=1;stobe output pause 2 portA.bit0=0;
portC=segment(1);set next seen segment output ;and strobe portA.bit1=1 pause 2 portA.bit1=0
portC=segment(2) portA.bit2=1 pause 2 portA.bit2=0
portC=segment(3) portA.bit3=1 pause 2 portA.bit3=0
Return
|