eblc1388
Active Member
ljcox said:Edit 3. The PIC programming may be a bit complicated as you are muxing on the segment side
I would suggest using table lookup. My idea is like the following, untested:
First, we isolate the special case of digit value=8(all segments ON) and 9(one segment OFF) in initial check routine and handle them separately.
If the current digit value is not 8 or 9, then we do a table lookup(or rotate 1 left by n times) for 0-7 to get an eight bit number which has a single nth bit set as per the digit value.
Next do another table lookup (0 for segment "a" and 6 for segment "g") and obtain a 8-bit return value which determine which digit value(0-7) the segment should be ON. We AND the two values together and set or clear the corresponding port bit according to whether the result is zero or not.