Code:
SYMBOL SDA=PORTA.O 'this is just an example
SYMBOL SCL=PORTA.1 'you can use other ports
'---------------senging four digits to SAA1064--------------------------------------
I2CWRITE SDA,SCL,$70,0,$B7,[dig1,dig2,dig3,dig4]
$70 is adress byte, you allready have that fixed,
0 is instruction byte, by this you tell the chip that next byte is control byte (see datasheet, first line in subadressing),
and every following byte is written from this point.
$B7 is control byte or 10110111 and means:
0 bit determines are you in static (2 digits) or dynamic multiplex (4 digits) mode
1 bit turns off/on digits 1 and 3
2 bit turns off/on digits 2 and 4
3 bit is used for testing all segments, normally is 0
4 bit +3mA
5 bit +6mA
6 bit +12mA
7 bit not used, could be anything
So, $B7 would be: you are in dynamic mode, 4 digits on, not testing, 3+6=9mA into segments.
Or, it could be $77: you are in dynamic mode, 4 digits on, not testing, 3+6+12=21mA into segments.
You send digits in hex, for an example $7D is number 7.
You can send constants with I2CWRITE or use variables for control registers and change them wherever you want in program.
My english is not so good so....sorry if I made any mistakes.
Bookmarks