⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blinky.lst

📁 采用C51编写的基于C8051F020单片机的定时器实用程序。
💻 LST
字号:
C51 COMPILER V6.23a  BLINKY                                                                12/19/2002 15:52:33 PAGE 1   


C51 COMPILER V6.23a, COMPILATION OF MODULE BLINKY
OBJECT MODULE PLACED IN Blinky.OBJ
COMPILER INVOKED BY: C:\KEIL\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: 4 SEP 01
   8          //
   9          // This program flashes the green LED on the C8051F020 target board about five times
  10          // a second using the interrupt handler for Timer3.
  11          // Target: C8051F02x
  12          //
  13          // Tool chain: KEIL Eval 'c'
  14          //
  15          
  16          //------------------------------------------------------------------------------------
  17          // Includes
  18          //------------------------------------------------------------------------------------
  19          #include <c8051f020.h>                    // SFR declarations
  20          
  21          //------------------------------------------------------------------------------------
  22          // 16-bit SFR Definitions for 'F02x
  23          //------------------------------------------------------------------------------------
  24          
  25          sfr16 DP       = 0x82;                    // data pointer
  26          sfr16 TMR3RL   = 0x92;                    // Timer3 reload value
  27          sfr16 TMR3     = 0x94;                    // Timer3 counter
  28          sfr16 ADC0     = 0xbe;                    // ADC0 data
  29          sfr16 ADC0GT   = 0xc4;                    // ADC0 greater than window
  30          sfr16 ADC0LT   = 0xc6;                    // ADC0 less than window
  31          sfr16 RCAP2    = 0xca;                    // Timer2 capture/reload
  32          sfr16 T2       = 0xcc;                    // Timer2
  33          sfr16 RCAP4    = 0xe4;                    // Timer4 capture/reload
  34          sfr16 T4       = 0xf4;                    // Timer4
  35          sfr16 DAC0     = 0xd2;                    // DAC0 data
  36          sfr16 DAC1     = 0xd5;                    // DAC1 data
  37          //------------------------------------------------------------------------------------
  38          // Global CONSTANTS
  39          //------------------------------------------------------------------------------------
  40          
  41          #define SYSCLK 2000000                    // approximate SYSCLK frequency in Hz
*** WARNING C317 IN LINE 41 OF Blinky.c: redefinition of macro 'SYSCLK'
  42          
  43          //sbit  LED = P1^6;                         //  LED: '1' = ON; '0' = OFF
  44          //sbit LED1=P1^0;
  45          
  46          //------------------------------------------------------------------------------------
  47          // Function PROTOTYPES
  48          //------------------------------------------------------------------------------------
  49          void PORT_Init (void);
  50          void Timer3_Init (int counts);
  51          void Timer3_ISR (void);
  52          unsigned int xdata  p2led[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
  53          //------------------------------------------------------------------------------------
  54          // MAIN Routine
C51 COMPILER V6.23a  BLINKY                                                                12/19/2002 15:52:33 PAGE 2   

  55          //------------------------------------------------------------------------------------
  56          void main (void) {
  57   1      
  58   1       
  59   1         // disable watchdog timer
  60   1         WDTCN = 0xde;
  61   1         WDTCN = 0xad;
  62   1              
  63   1         PORT_Init ();
  64   1         Timer3_Init (SYSCLK / 12 / 10);        // Init Timer3 to generate interrupts
  65   1                                                // at a 10Hz rate.
  66   1         //LED1=1;
  67   1        
  68   1         EA = 1;                                                                                      // enable global interrupts
  69   1      
  70   1         while (1) {                            // spin forever
  71   2         }
  72   1      }
  73          
  74          //------------------------------------------------------------------------------------
  75          // PORT_Init
  76          //------------------------------------------------------------------------------------
  77          //
  78          // Configure the Crossbar and GPIO ports
  79          //
  80          void PORT_Init (void)
  81          {
  82   1         XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
  83   1         //P1MDOUT |= 0x41;                    // enable P1.6 (LED) as push-pull output
  84   1      }
  85          
  86          //------------------------------------------------------------------------------------
  87          // Timer3_Init
  88          //------------------------------------------------------------------------------------
  89          //
  90          // Configure Timer3 to auto-reload and generate an interrupt at interval
  91          // specified by <counts> using SYSCLK/12 as its time base.
  92          //
  93          void Timer3_Init (int counts)
  94          {
  95   1         TMR3CN = 0x00;                      // Stop Timer3; Clear TF3;
  96   1                                             // use SYSCLK/12 as timebase
  97   1         TMR3RL  = -counts;                  // Init reload values
  98   1         TMR3    = 0xffff;                   // set to reload immediately
  99   1         EIE2   |= 0x01;                     // enable Timer3 interrupts
 100   1         TMR3CN |= 0x04;                     // start Timer3
 101   1      }
 102          
 103          //------------------------------------------------------------------------------------
 104          // Interrupt Service Routines
 105          //------------------------------------------------------------------------------------
 106          
 107          //------------------------------------------------------------------------------------
 108          // Timer3_ISR
 109          //------------------------------------------------------------------------------------
 110          // This routine changes the state of the LED whenever Timer3 overflows.
 111          //
 112          
 113          void Timer3_ISR (void) interrupt 14
 114          {
 115   1         
 116   1         static int count;
C51 COMPILER V6.23a  BLINKY                                                                12/19/2002 15:52:33 PAGE 3   

 117   1         static int i=9,j=0;
 118   1         static int led=0xff;
 119   1         
 120   1         TMR3CN &= ~(0x80); // clear TF3
 121   1         count++;
 122   1         if(count==5)
 123   1         {count=0;
 124   2          P3=led;
 125   2              P2=p2led[j];
 126   2              led=led<<1;
 127   2          i--;
 128   2              j++;
 129   2              if(j==8)
 130   2              j=0;
 131   2          if(i==0)
 132   2           {i=9;
 133   3            led=0xff;
 134   3            } 
 135   2          }
 136   1              }
 137              //LED = ~LED;// change state of LED


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    177    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =     16    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      8    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  1 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -