📄 max7219.lst
字号:
C51 COMPILER V8.02 MAX7219 05/17/2009 18:24:25 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MAX7219
OBJECT MODULE PLACED IN max7219.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE max7219.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg51.h>
2
3
4 /*macro define*/
5 #define HIGH 1
6 #define LOW 0
7 #define TRUE 1
8 #define FALSE 0
9 #define ZERO 0
10 #define MSB 0x80
11 #define LSB 0x01
12
13 /*mode define*/
14 #define NO_OP 0x00
15 #define DECODE_MODE 0x09
16 #define INTENSITY 0x0A
17 #define SCAN_LIMIT 0x0B
18 #define SHUTDOWN 0x0C
19 #define DISPLAY_TEST 0x0F
20
21 /*pin define*/
22 sbit DIN = P2^5; //MAX7219 Serial-Data Input: rising edge pin 1
23 sbit LOAD = P2^6; //MAX7219 Load-Data Input: rising edge pin 12
24 sbit CLK = P2^7; //MAX7219 Serial-Clock Input: maximum 10MHz pin 13
25
26 /*funtion define*/
27 void Init_Max7219(void);//initialize max7219
28 void Write_Max7219_byte(unsigned char temp);//send max7219 a byte
29 void Write_Max7219(unsigned char address,unsigned char dat);//send max7219 command and data
30 void Show_Max7219(unsigned int left,unsigned int right) reentrant;//十进制显示,第一个参数是7219左四位,第
-二个是右四位
31 void Byte_Max7219(unsigned char byte_data);//十进制输出一字节数据
32 void Regprint_Max7219(unsigned char byte_data);//二进制输出一字节数据,用于打印八位寄存器
33 void Interger_Max7219(unsigned long int interger) reentrant;//显示十进制整形数
34
35 /************************************************************************************
36 code of funtions
37 ************************************************************************************/
38
39 void Write_Max7219_byte(unsigned char temp)
40 {
41 1 unsigned char i;
42 1 for (i=0;i<8;i++)
43 1 {
44 2
45 2 CLK=LOW;
46 2
47 2
48 2 DIN=(bit)(temp&MSB);
49 2 temp<<=1;
50 2
51 2 CLK=HIGH;
52 2 }
53 1 }
54
C51 COMPILER V8.02 MAX7219 05/17/2009 18:24:25 PAGE 2
55 void Write_Max7219(unsigned char address,unsigned char dat)
56 {
57 1 LOAD=LOW;
58 1 Write_Max7219_byte(address);
59 1 Write_Max7219_byte(dat);
60 1 LOAD=HIGH;
61 1 }
62
63 void Init_Max7219(void)
64 {
65 1 Write_Max7219(SHUTDOWN, 0x01);//Normal Operation
66 1 Write_Max7219(DISPLAY_TEST, 0x00);//Normal Operation
67 1 Write_Max7219(DECODE_MODE, 0xff);//Code B decode for digits 7-0
68 1 Write_Max7219(SCAN_LIMIT, 0x07);//Display digits 7-0
69 1 Write_Max7219(INTENSITY, 0x02);//Duty Cycle 9/32
70 1 }
71
72 void Show_Max7219(unsigned int left,unsigned int right) reentrant
73 {
74 1 unsigned char i,digit_l,digit_r;
75 1
76 1 for(i=8;i>4;i--)
77 1 {
78 2 digit_l=left%10;
79 2 Write_Max7219(i-4,digit_l);
80 2 left/=10;
81 2
82 2 digit_r=right%10;
83 2 Write_Max7219(i,digit_r);
84 2 right/=10;
85 2 }
86 1 }
87
88 void Byte_Max7219(unsigned char byte_data)
89 {
90 1 unsigned char i,digit;
91 1
92 1 for(i=8;i>0;i--)
93 1 {
94 2 digit=byte_data%10;
95 2 Write_Max7219(i,digit);
96 2 byte_data/=10;
97 2 }
98 1 }
99
100 void Regprint_Max7219(unsigned char byte_data)
101 {
102 1 unsigned char i,reg_bit,test_bit=0x01;
103 1
104 1 for(i=8;i>0;i--)
105 1 {
106 2 reg_bit=byte_data&test_bit;
107 2 Write_Max7219(i,reg_bit);
108 2 byte_data=byte_data>>1;
109 2 }
110 1 }
111
112 void Interger_Max7219(unsigned long int interger) reentrant
113 {
114 1 unsigned char i,digit;
115 1
116 1 for(i=8;i>0;i--)
C51 COMPILER V8.02 MAX7219 05/17/2009 18:24:25 PAGE 3
117 1 {
118 2 digit=interger%10;
119 2 Write_Max7219(i,digit);
120 2 interger/=10;
121 2 }
122 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 376 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -