1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
| #include <main.h>
#define MAX6955BaseAddress 0b11000000
#define reg_noOp 0x00
#define reg_decodeMode 0x01
#define reg_globalIntensity 0x02
#define reg_scanLimit 0x03
#define reg_configuration 0x04
#define reg_displayTest 0x07
#define reg_digitType 0x0C
#define reg_intensity10 0x10
#define reg_intensity32 0x11
#define reg_intensity54 0x12
#define reg_intensity76 0x13
#define reg_intensity10a 0x14
#define reg_intensity32a 0x15
#define reg_intensity54a 0x16
#define reg_intensity76a 0x17
#define USE_GLOBAL 0x00
#define USE_DISCRETE 0x40
#define RUN 0x01
#define SHUTDOWN 0x00
#define reg_digit0 0x60
#define reg_digit1 0x61
#define reg_digit2 0x62
#define reg_digit3 0x63
#define reg_digit4 0x64
#define reg_digit5 0x65
#define reg_digit6 0x66
#define reg_digit7 0x67
#define reg_digit0a 0x68
#define reg_digit1a 0x69
#define reg_digit2a 0x6A
#define reg_digit3a 0x6B
#define reg_digit4a 0x6C
#define reg_digit5a 0x6D
#define reg_digit6a 0x6E
#define reg_digit7a 0x6F
void writeMAX6955(int8, int8, int8);
void initMAX6955(int8);
void writeMAX6955(int8 driver, int8 command, int8 data)
{
i2c_start();
i2c_write(MAX6955BaseAddress + (driver<<1));
i2c_write(command);
i2c_write(data);
i2c_stop();
}
void initMAX6955(int8 driver)
{
writeMAX6955(driver, reg_decodeMode, 0x00);
writeMAX6955(driver, reg_scanLimit, 0x07);
writeMAX6955(driver, reg_configuration, (RUN|USE_DISCRETE));
writeMAX6955(driver, reg_globalIntensity, 0x0F);
writeMAX6955(driver, reg_digitType, 0x00);
writeMAX6955(driver, reg_displayTest, 0x01);
delay_ms(1000);
writeMAX6955(driver, reg_displayTest, 0x00);
writeMAX6955(driver, 0x04, 0x01);
}
void main(){
initMAX6955(0);
while(1){
writeMAX6955(0, 0x20, 0x4D);
writeMAX6955(0, 0x21, 0x41);
writeMAX6955(0, 0x22, 0x58);
writeMAX6955(0, 0x23, 0x49);
writeMAX6955(0, 0x24, 0x4D);
writeMAX6955(0, 0x25, 0x2D);
writeMAX6955(0, 0x26, 0x49);
writeMAX6955(0, 0x27, 0x43);
}
} |