📄 led_mx4.lst
字号:
199 =2 sbit RS0 = 0xD3;
200 =2 sbit RS1 = 0xD4;
201 =2 sbit F0 = 0xD5;
202 =2 sbit AC = 0xD6;
203 =2 sbit CY = 0xD7;
204 =2
205 =2 /*------------------------------------------------
206 =2 Interrupt Vectors:
207 =2 Interrupt Address = (Number * 8) + 3
208 =2 ------------------------------------------------*/
209 =2 #define IE0_VECTOR 0 /* 0x03 External Interrupt 0 */
210 =2 #define TF0_VECTOR 1 /* 0x0B Timer 0 */
211 =2 #define IE1_VECTOR 2 /* 0x13 External Interrupt 1 */
212 =2 #define TF1_VECTOR 3 /* 0x1B Timer 1 */
213 =2 #define SIO_VECTOR 4 /* 0x23 Serial port */
214 =2
215 =2 #define TF2_VECTOR 5 /* 0x2B Timer 2 */
216 =2 #define EX2_VECTOR 5 /* 0x2B External Interrupt 2 */
217 =2
218 =2 /*------------------------------------------------
219 =2 ------------------------------------------------*/
220 =2 #endif
221 =2
222 =2
33 =1
34 =1 // Include oscillator / chip details here
35 =1 // (essential if generic delays / timeouts are used)
36 =1 // -
37 =1 // Oscillator / resonator frequency (in Hz) e.g. (11059200UL)
38 =1 #define OSC_FREQ (12000000UL)
39 =1
40 =1 // Number of oscillations per instruction (4, 6 or 12)
41 =1 // 12 - Original 8051 / 8052 and numerous modern versions
42 =1 // 6 - Various Infineon and Philips devices, etc.
43 =1 // 4 - Dallas, etc.
44 =1 //
45 =1 // Take care with Dallas devices
46 =1 // - Timers default to *12* osc ticks unless CKCON is modified
47 =1 // - If using generic code on a Dallas device, use 12 here
48 =1 #define OSC_PER_INST (12)
49 =1
50 =1 //------------------------------------------------------------------
51 =1 // SHOULD NOT NEED TO EDIT THE SECTIONS BELOW
52 =1 //------------------------------------------------------------------
53 =1 typedef unsigned char tByte;
54 =1 typedef unsigned int tWord;
55 =1 typedef unsigned long tLong;
C51 COMPILER V6.10 LED_MX4 04/18/2001 16:18:12 PAGE 6
56 =1
57 =1 // Misc #defines
58 =1 #ifndef TRUE
59 =1 #define FALSE 0
60 =1 #define TRUE (!FALSE)
61 =1 #endif
62 =1
63 =1 #define RETURN_NORMAL (bit) 0
64 =1 #define RETURN_ERROR (bit) 1
65 =1
66 =1
67 =1 //------------------------------------------------------------------
68 =1 // Interrupts
69 =1 // - see Chapter 13.
70 =1 //------------------------------------------------------------------
71 =1
72 =1 // Generic 8051/52 timer interrupts (used in most schedulers)
73 =1 #define INTERRUPT_Timer_0_Overflow 1
74 =1 #define INTERRUPT_Timer_1_Overflow 3
75 =1 #define INTERRUPT_Timer_2_Overflow 5
76 =1
77 =1 // Additional interrupts (used in shared-clock schedulers)
78 =1 #define INTERRUPT_EXTERNAL_0 0
79 =1 #define INTERRUPT_EXTERNAL_1 2
80 =1 #define INTERRUPT_UART_Rx_Tx 4
81 =1 #define INTERRUPT_CAN_c515c 17
82 =1
83 =1 //------------------------------------------------------------------
84 =1 // Error codes
85 =1 // - see Chapter 14.
86 =1 //------------------------------------------------------------------
87 =1
88 =1 #define ERROR_SCH_TOO_MANY_TASKS (1)
89 =1 #define ERROR_SCH_CANNOT_DELETE_TASK (2)
90 =1
91 =1 #define ERROR_SCH_WAITING_FOR_SLAVE_TO_ACK (3)
92 =1 #define ERROR_SCH_WAITING_FOR_START_COMMAND_FROM_MASTER (3)
93 =1
94 =1 #define ERROR_SCH_ONE_OR_MORE_SLAVES_DID_NOT_START (4)
95 =1 #define ERROR_SCH_LOST_SLAVE (5)
96 =1
97 =1 #define ERROR_SCH_CAN_BUS_ERROR (6)
98 =1
99 =1 #define ERROR_I2C_WRITE_BYTE (10)
100 =1 #define ERROR_I2C_READ_BYTE (11)
101 =1 #define ERROR_I2C_WRITE_BYTE_AT24C64 (12)
102 =1 #define ERROR_I2C_READ_BYTE_AT24C64 (13)
103 =1 #define ERROR_I2C_DS1621 (14)
104 =1
105 =1 #define ERROR_USART_TI (21)
106 =1 #define ERROR_USART_WRITE_CHAR (22)
107 =1
108 =1 #define ERROR_SPI_EXCHANGE_BYTES_TIMEOUT (31)
109 =1 #define ERROR_SPI_X25_TIMEOUT (32)
110 =1 #define ERROR_SPI_MAX1110_TIMEOUT (33)
111 =1
112 =1 #define ERROR_ADC_MAX150_TIMEOUT (44)
113 =1
114 =1 #endif
115 =1
116 =1 /*------------------------------------------------------------------*-
117 =1 ---- END OF FILE -------------------------------------------------
C51 COMPILER V6.10 LED_MX4 04/18/2001 16:18:12 PAGE 7
118 =1 -*------------------------------------------------------------------*/
26 #include "Port.h"
1 =1 /*------------------------------------------------------------------*-
2 =1
3 =1 Port.H (v1.00)
4 =1
5 =1 ------------------------------------------------------------------
6 =1
7 =1 'Port Header' (see Chap 10) for project ELAPSED (see Chap 21)
8 =1
9 =1
10 =1 COPYRIGHT
11 =1 ---------
12 =1
13 =1 This code is from the book:
14 =1
15 =1 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
16 =1 [Pearson Education, 2001; ISBN: 0-201-33138-1].
17 =1
18 =1 This code is copyright (c) 2001 by Michael J. Pont.
19 =1
20 =1 See book for copyright details and other information.
21 =1
22 =1 -*------------------------------------------------------------------*/
23 =1
24 =1 // ------ Sch51.C ----------------------------------------
25 =1
26 =1 // Comment this line out if error reporting is NOT required
27 =1 #define SCH_REPORT_ERRORS
28 =1
29 =1 #ifdef SCH_REPORT_ERRORS
30 =1 // The port on which error codes will be displayed
31 =1 // ONLY USED IF ERRORS ARE REPORTED
32 =1 #define Error_port P1
33 =1
34 =1 #endif
35 =1
36 =1 // ------ LED_MX4.C -----------------------------------------------
37 =1
38 =1 // LED connection requires 12 port pins
39 =1 #define LED_DATA_PORT (P2)
40 =1
41 =1 /* Connections to LED_DATA_PORT - See Figure 21.6 for details
42 =1
43 =1 DP G F E D C B A = LED display pins
44 =1 | | | | | | | |
45 =1 x.7 x.6 x.5 x.4 x.3 x.2 x.1 x.0 = Port pins
46 =1
47 =1 x.7 == LED_DATA_PORT^7, etc
48 =1
49 =1 LED codes (NB - positive logic assumed here)
50 =1
51 =1 0 = abcdef => 00111111 = 0x3F
52 =1 1 = bc => 00000110 = 0x06
53 =1 2 = abdeg => 01011011 = 0x5B
54 =1 3 = abcdg => 01001111 = 0x4F
55 =1 4 = bcfg => 01100110 = 0x66
56 =1 5 = acdfg => 01101101 = 0x6D
57 =1 6 = acdefg => 01111101 = 0x7D
58 =1 7 = abc => 00000111 = 0x07
59 =1 8 = abcdefg => 01111111 = 0x7F
60 =1 9 = abcdfg => 01101111 = 0x6F
C51 COMPILER V6.10 LED_MX4 04/18/2001 16:18:12 PAGE 8
61 =1
62 =1 To display decimal point, add 10 (decimal) to the above values */
63 =1
64 =1 // Any combination of (4) pins on any ports may be used here
65 =1 sbit LED_DIGIT_0 = P3^3;
66 =1 sbit LED_DIGIT_1 = P3^4;
67 =1 sbit LED_DIGIT_2 = P3^5;
68 =1 sbit LED_DIGIT_3 = P3^6;
69 =1
70 =1
71 =1 /*------------------------------------------------------------------*-
72 =1 ---- END OF FILE -------------------------------------------------
73 =1 -*------------------------------------------------------------------*/
74 =1
75 =1
76 =1
27
28 #include "LED_Mx4.h"
1 =1 /*------------------------------------------------------------------*-
2 =1
3 =1 LED_Mx4.H (v1.00)
4 =1
5 =1 ------------------------------------------------------------------
6 =1
7 =1 - See LED_Mx4.C for details.
8 =1
9 =1
10 =1 COPYRIGHT
11 =1 ---------
12 =1
13 =1 This code is from the book:
14 =1
15 =1 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
16 =1 [Pearson Education, 2001; ISBN: 0-201-33138-1].
17 =1
18 =1 This code is copyright (c) 2001 by Michael J. Pont.
19 =1
20 =1 See book for copyright details and other information.
21 =1
22 =1 -*------------------------------------------------------------------*/
23 =1
24 =1 // ------ Public constants -----------------------------------------
25 =1
26 =1 #define LED_NUM_DIGITS (4)
27 =1
28 =1 // ------ Public function prototypes -------------------------------
29 =1
30 =1 void LED_MX4_Display_Update(void);
31 =1
32 =1 /*------------------------------------------------------------------*-
33 =1 ---- END OF FILE -------------------------------------------------
34 =1 -*------------------------------------------------------------------*/
29
30 // ------ Public variable definitions ------------------------------
31
32 // Lookup table - stored in code area
33 // See Port.H for connections and code details
34
35 tByte code LED_Table_G[20] =
36 // 0 1 2 3 4 5 6 7 8 9
37 {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F,
38 // 0. 1. 2. 3. 4. 5. 6. 7. 8. 9.
C51 COMPILER V6.10 LED_MX4 04/18/2001 16:18:12 PAGE 9
39 0xBF, 0x86, 0xDB, 0xCF, 0xE6, 0xED, 0xFD, 0x87, 0xFF, 0xEF};
40
41 // Global data formatted for display (initially 0,0,0,0)
42 tByte LED_Mx4_Data_G[4] = {0x3F,0x3F,0x3F,0x3F};
43
44
45 // ------ Private variable definitions------------------------------
46
47 static tByte Digit_G;
48
49 /*------------------------------------------------------------------*-
50
51 LED_MX4_Display_Update()
52
53 Updates (four) multiplexed 8-segment LED displays.
54
55 Usually aim to scheduled at around 3ms intervals: typically
56 around a 1% CPU load on standard 8051.
57
58 -*------------------------------------------------------------------*/
59 void LED_MX4_Display_Update(void)
60 {
61 1 // Increment the digit to be displayed
62 1 if (++Digit_G == LED_NUM_DIGITS)
63 1 {
64 2 Digit_G = 0;
65 2 }
66 1
67 1 // Allows any pins to be used
68 1 switch (Digit_G)
69 1 {
70 2 case 0:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -