?? timer.lst
字號:
C51 COMPILER V7.09 TIMER 07/27/2007 15:11:24 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE TIMER
OBJECT MODULE PLACED IN TIMER.obj
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE tcp\TIMER.C LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\TIMER.lst) OBJECT(TIMER
-.obj)
line level source
1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2002 Jim Brady
3 // Do not use commercially without author's permission
4 // Last revised August 2002
5 // Net TIMER.C
6 //
7 // This module sets up the timer and handles the timer interrupt
8 //-----------------------------------------------------------------------------
9 #include "net.h"
10 #include "timer.h"
11 #include "global.h"
12
13
14 extern uint event_word;
15 extern ulong initial_sequence_nr;
16
17 #ifdef __cplusplus
extern "C"{
#endif
20 //--------------------------------------------------------------------------
21 // Timer 2 interrupt service routing. Intr vector location is
22 // address 0x002B. The timer generates an interrupt every 25 msec
23 // It is set to auto reload so do not need to reload it.
24 //--------------------------------------------------------------------------
25 void timer2_interrupt(void)
26 {
27 1 static uint count1 = 0;
28 1 static uint count2 = 0;
29 1
30 1 TF2 = 0; // Clear interrupt flag
31 1
32 1 // Advance the initial sequence number
33 1 initial_sequence_nr += 6250;
34 1 // Keep it some distance from rolling over
35 1 if (initial_sequence_nr & 0x10000000L)
36 1 initial_sequence_nr = 1;
37 1
38 1 count1++;
39 1 // These events happens every 0.50 seconds, not simultaneously
40 1 if (count1 == 5)
41 1 event_word |= EVENT_ARP_RETRANSMIT;
42 1
43 1 if (count1 == 10)
44 1 event_word |= EVENT_TCP_INACTIVITY; //TCP保活時間標志
45 1
46 1 if (count1 == 15)
47 1 event_word |= EVENT_READ_ANALOG;
48 1
49 1 if (count1 == 20)
50 1 {
51 2 count1 = 0;
52 2 event_word |= EVENT_TCP_RETRANSMIT; //TCP重發事件標志
53 2 }
54 1
C51 COMPILER V7.09 TIMER 07/27/2007 15:11:24 PAGE 2
55 1 count2++;
56 1 if (count2 == 2401)
57 1 {
58 2 // This happens every 60.025 seconds, not simultaneous
59 2 // with above tasks
60 2 count2 = 0;
61 2 event_word |= EVENT_AGE_ARP_CACHE; //ARP CACHE刷新事件標志
62 2 }
63 1 }
64
65
66 #ifdef __cplusplus
}
#endif
69
70
71 //--------------------------------------------------------------------------
72 // Setup Timer2 in mode 1 which is 16 bit auto reload
73 // Intr rate = 22.1184 MHz /(12 * (65536 - reload value))
74 // For 25 msec reload value = 19456 = 0x4C00
75 //--------------------------------------------------------------------------
76 void init_timer2(void)
77 {
78 1 T2CON = 0x00;
79 1 RCAP2H = 0x4C; // Reload value
80 1 RCAP2L = 0x00;
81 1 TH2 = 0x4C; // Initial load value
82 1 TL2 = 0x00;
83 1 TR2 = 1; // Timer 2 run
84 1 }
85
86
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 207 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 4 ----
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 + -