📄 pulcnt_s.lst
字号:
C51 COMPILER V6.10 PULCNT_S 04/19/2001 11:59:24 PAGE 1
C51 COMPILER V6.10, COMPILATION OF MODULE PULCNT_S
OBJECT MODULE PLACED IN .\PULCNT_S.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE .\PULCNT_S.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*------------------------------------------------------------------*-
2
3 PulCnt_S.C (v1.00)
4
5 ------------------------------------------------------------------
6
7 Software pulse-count library (see Chapter 30).
8
9
10 COPYRIGHT
11 ---------
12
13 This code is from the book:
14
15 PATTERNS FOR TIME-TRIGGERED EMBEDDED SYSTEMS by Michael J. Pont
16 [Pearson Education, 2001; ISBN: 0-201-33138-1].
17
18 This code is copyright (c) 2001 by Michael J. Pont.
19
20 See book for copyright details and other information.
21
22 -*------------------------------------------------------------------*/
23
24 #include "Main.h"
25 #include "Port.h"
26
27 #include "Bargraph.h"
28 #include "PulCnt_S.h"
29
30 // ------ Public variable definitions -----------------------------
31
32 // Stores the average count value
33 extern tBargraph Count_G;
34
35 // ------ Private constants ----------------------------------------
36
37 #define PULSE_HIGH (1)
38 #define PULSE_LOW (0)
39
40 // ------ Private variable definitions------------------------------
41
42 // Stores the instantaneous count value
43 static tWord Count_local_G;
44
45 // The previous state of the pulse-count pin
46 static bit Previous_state_G;
47
48 /*------------------------------------------------------------------*-
49
50 PC_SOFT_Init()
51
52 Prepare for software pulse counts.
53
54 -*------------------------------------------------------------------*/
55 void PC_SOFT_Init(void)
C51 COMPILER V6.10 PULCNT_S 04/19/2001 11:59:24 PAGE 2
56 {
57 1 Count_local_G = 0;
58 1 Count_G = 0;
59 1 }
60
61 /*------------------------------------------------------------------*-
62
63 PC_SOFT_Poll_Count()
64
65 Using software to count falling edges on a specified pin
66 - T0 is *NOT* used here.
67
68 -*------------------------------------------------------------------*/
69 void PC_SOFT_Poll_Count(void)
70 {
71 1 bit State = Count_pin;
72 1
73 1 if ((Previous_state_G == PULSE_HIGH) && (State == PULSE_LOW))
74 1 {
75 2 Count_local_G++;
76 2 }
77 1
78 1 Previous_state_G = State;
79 1 }
80
81 /*------------------------------------------------------------------*-
82
83 PC_SOFT_Get_Count()
84
85 Schedule this function at regular intervals.
86
87 Copies 'polled' count to global variable.
88
89 -*------------------------------------------------------------------*/
90 void PC_SOFT_Get_Count(void)
91 {
92 1 Count_G = Count_local_G;
93 1 Count_local_G = 0;
94 1 }
95
96 /*------------------------------------------------------------------*-
97 ---- END OF FILE -------------------------------------------------
98 -*------------------------------------------------------------------*/
99
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 45 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 ----
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -