📄 simple_eos.lst
字号:
C51 COMPILER V6.21 SIMPLE_EOS 01/23/2002 18:02:34 PAGE 1
C51 COMPILER V6.21, COMPILATION OF MODULE SIMPLE_EOS
OBJECT MODULE PLACED IN Simple_EOS.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Simple_EOS.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*------------------------------------------------------------------*-
2
3 Simple_EOS.C (v1.00)
4
5 ------------------------------------------------------------------
6
7 Main file for Simple Embedded Operating System (sEOS) for 8051.
8
9 - This version for washing-machine controller (demo).
10
11 COPYRIGHT
12 ---------
13
14 This code is associated with the book:
15
16 EMBEDDED C by Michael J. Pont
17 [Pearson Education, 2002: ISBN: 0-201-79523-X].
18
19 This code is copyright (c) 2001 by Michael J. Pont.
20
21 See book for copyright details and other information.
22
23 -*------------------------------------------------------------------*/
24
25 #include "Main.H"
26 #include "Simple_EOS.H"
27
28 #include "Washer.H"
29
30 // ------ Private variable definitions -----------------------------
31 static tByte Call_count_G;
32
33
34 /*------------------------------------------------------------------*-
35
36 sEOS_ISR()
37
38 Invoked periodically by Timer 2 overflow:
39 see sEOS_Init_Timer2() for timing details.
40
41 -*------------------------------------------------------------------*/
42 void sEOS_ISR() interrupt INTERRUPT_Timer_2_Overflow
43 {
44 1 // Must manually reset the T2 flag
45 1 TF2 = 0;
46 1
47 1 //===== USER CODE - Begin =======================================
48 1 // This ISR is called every 50 ms
49 1 // - only want to update washer every second
50 1 if (++Call_count_G < 20)
51 1 {
52 2 return;
53 2 }
54 1
55 1 // Time to update LED
C51 COMPILER V6.21 SIMPLE_EOS 01/23/2002 18:02:34 PAGE 2
56 1 Call_count_G = 0;
57 1
58 1 // Call washer update function
59 1 WASHER_Update();
60 1 //===== USER CODE - End =========================================
61 1 }
62
63 /*------------------------------------------------------------------*-
64
65 sEOS_Init_Timer2()
66
67 Sets up Timer 2 to drive the simple EOS.
68
69 Parameter gives tick interval in MILLISECONDS.
70
71 Max tick interval is ~60ms (12 MHz oscillator).
72
73 Note: Precise tick intervals are only possible with certain
74 oscillator / tick interval combinations. If timing is important,
75 you should check the timing calculations manually.
76
77 -*------------------------------------------------------------------*/
78 void sEOS_Init_Timer2(const tByte TICK_MS)
79 {
80 1 tLong Inc;
81 1 tWord Reload_16;
82 1 tByte Reload_08H, Reload_08L;
83 1
84 1 // Timer 2 is configured as a 16-bit timer,
85 1 // which is automatically reloaded when it overflows
86 1 T2CON = 0x04; // Load Timer 2 control register
87 1
88 1 // Number of timer increments required (max 65536)
89 1 Inc = ((tLong)TICK_MS * (OSC_FREQ/1000)) / (tLong)OSC_PER_INST;
90 1
91 1 // 16-bit reload value
92 1 Reload_16 = (tWord) (65536UL - Inc);
93 1
94 1 // 8-bit reload values (High & Low)
95 1 Reload_08H = (tByte)(Reload_16 / 256);
96 1 Reload_08L = (tByte)(Reload_16 % 256);
97 1
98 1 // Used for manually checking timing (in simulator)
99 1 //P2 = Reload_08H;
100 1 //P3 = Reload_08L;
101 1
102 1 TH2 = Reload_08H; // Load Timer 2 high byte
103 1 RCAP2H = Reload_08H; // Load Timer 2 reload capt. reg. high byte
104 1 TL2 = Reload_08L; // Load Timer 2 low byte
105 1 RCAP2L = Reload_08L; // Load Timer 2 reload capt. reg. low byte
106 1
107 1 // Timer 2 interrupt is enabled, and ISR will be called
108 1 // whenever the timer overflows.
109 1 ET2 = 1;
110 1
111 1 // Start Timer 2 running
112 1 TR2 = 1;
113 1
114 1 EA = 1; // Globally enable interrupts
115 1 }
116
117 /*------------------------------------------------------------------*-
C51 COMPILER V6.21 SIMPLE_EOS 01/23/2002 18:02:34 PAGE 3
118
119 sEOS_Go_To_Sleep()
120
121 This operating system enters 'idle mode' between clock ticks
122 to save power. The next clock tick will return the processor
123 to the normal operating state.
124
125 *** ADAPT AS REQUIRED FOR YOUR HARDWARE ***
126
127 -*------------------------------------------------------------------*/
128 void sEOS_Go_To_Sleep(void)
129 {
130 1 PCON |= 0x01; // Enter idle mode (generic 8051 version)
131 1 }
132
133 /*------------------------------------------------------------------*-
134 ---- END OF FILE -------------------------------------------------
135 -*------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 135 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 4
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 + -