📄 blinky.lst
字号:
C51 COMPILER V6.14 BLINKY 12/06/2008 23:38:55 PAGE 1
C51 COMPILER V6.14, COMPILATION OF MODULE BLINKY
OBJECT MODULE PLACED IN Blinky.OBJ
COMPILER INVOKED BY: C:\CYGNAL\IDEfiles\C51\BIN\C51.exe Blinky.c DB OE
stmt level source
1 //------------------------------------------------------------------------------------
2 // Blinky.c
3 //------------------------------------------------------------------------------------
4 // Copyright 2001 Cygnal Integrated Products, Inc.
5 //
6 // AUTH: BW
7 // DATE: 10 OCT 01
8 //
9 // This program flashes the green LED on the C8051F2xx target board about five times
10 // a second using the interrupt handler for Timer2.
11 //
12 // Target: C8051F2xx
13 //
14 // Tool chain: KEIL Eval 'c'
15 //
16
17 //------------------------------------------------------------------------------------
18 // Includes
19 //------------------------------------------------------------------------------------
20 #include <c8051f200.h> // SFR declarations
21
22 //------------------------------------------------------------------------------------
23 // 16-bit SFR Definitions for 'F2xx
24 //------------------------------------------------------------------------------------
25
26 sfr16 DP = 0x82; // data pointer
27 sfr16 ADC0 = 0xbe; // ADC0 data
28 sfr16 ADC0GT = 0xc4; // ADC0 greater than window
29 sfr16 ADC0LT = 0xc6; // ADC0 less than window
30 sfr16 RCAP2 = 0xca; // Timer2 capture/reload
31 sfr16 T2 = 0xcc; // Timer2
32
33 //------------------------------------------------------------------------------------
34 // Global CONSTANTS
35 //------------------------------------------------------------------------------------
36
37 #define SYSCLK 2000000 // approximate SYSCLK frequency in Hz
38
39 sbit LED = P2^4; // green LED: '1' = ON; '0' = OFF
40
41 //------------------------------------------------------------------------------------
42 // Function PROTOTYPES
43 //------------------------------------------------------------------------------------
44 void PORT_Init (void);
45 void Timer2_Init (int counts);
46 void Timer2_ISR (void);
47
48 //------------------------------------------------------------------------------------
49 // MAIN Routine
50 //------------------------------------------------------------------------------------
51 void main (void) {
52 1
53 1 // disable watchdog timer
54 1 WDTCN = 0xde;
55 1 WDTCN = 0xad;
C51 COMPILER V6.14 BLINKY 12/06/2008 23:38:55 PAGE 2
56 1
57 1 PORT_Init ();
58 1 Timer2_Init (SYSCLK / 12 / 10); // Init Timer2 to generate interrupts
59 1 // at a 10Hz rate.
60 1
61 1 EA = 1; // enable global interrupts
62 1
63 1 while (1) { // spin forever
64 2 }
65 1 }
66
67 //------------------------------------------------------------------------------------
68 // PORT_Init
69 //------------------------------------------------------------------------------------
70 //
71 // Configure port mux and GPIO ports
72 //
73 void PORT_Init (void)
74 {
75 1 PRT2CF |= 0x10; // enable P2.4 (LED) as push-pull output
76 1 }
77
78 //------------------------------------------------------------------------------------
79 // Timer2_Init
80 //------------------------------------------------------------------------------------
81 //
82 // Configure Timer2 to auto-reload and generate an interrupt at interval
83 // specified by <counts> using SYSCLK/12 as its time base.
84 //
85 void Timer2_Init (int counts)
86 {
87 1 T2CON = 0x00; // Stop Timer2; configure for auto-reload
88 1 CKCON &= ~0x20; // T2M=0 (use SYSCLK/12 as timebase)
89 1 RCAP2 = -counts; // Init reload value
90 1 T2 = 0xffff; // set to reload immediately
91 1 ET2 = 1; // enable Timer2 interrupts
92 1 TR2 = 1; // start Timer2
93 1 }
94
95 //------------------------------------------------------------------------------------
96 // Interrupt Service Routines
97 //------------------------------------------------------------------------------------
98
99 //------------------------------------------------------------------------------------
100 // Timer2_ISR
101 //------------------------------------------------------------------------------------
102 // This routine changes the state of the LED whenever Timer2 overflows.
103 //
104 void Timer2_ISR (void) interrupt 5
105 {
106 1 TF2 = 0; // clear Timer2 overflow interrupt flag
107 1 LED = ~LED; // change state of LED
108 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 55 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
C51 COMPILER V6.14 BLINKY 12/06/2008 23:38:55 PAGE 3
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 + -