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