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

📄 blinky.lst

📁 F120的最小系统,可以让初学者学习一下.方便好用
💻 LST
字号:
C51 COMPILER V8.08   BLINKY                                                                06/17/2008 18:13:51 PAGE 1   


C51 COMPILER V8.08, COMPILATION OF MODULE BLINKY
OBJECT MODULE PLACED IN blinky.OBJ
COMPILER INVOKED BY: C:\SiLabs\MCU\IDEfiles\C51\BIN\C51.exe blinky.c DB OE

line level    source

   1          //------------------------------------------------------------------------------------
   2          // Blinky.c
   3          //------------------------------------------------------------------------------------
   4          // Copyright (C) 2004 Silicon Laboratories, Inc.
   5          //
   6          // AUTH: BD
   7          // DATE: 1 JUL 2002
   8          //
   9          // This program flashes the green LED on the C8051F120 target board about five times
  10          // a second using the interrupt handler for Timer3.
  11          // Target: C8051F12x
  12          //
  13          // Tool chain: KEIL Eval 'c'
  14          //
  15          
  16          //------------------------------------------------------------------------------------
  17          // Includes
  18          //------------------------------------------------------------------------------------
  19          #include <c8051f120.h>                    // SFR declarations
  20          
  21          //-----------------------------------------------------------------------------
  22          // 16-bit SFR Definitions for 'F12x
  23          //-----------------------------------------------------------------------------
  24          
  25          sfr16 RCAP3    = 0xCA;                 // Timer3 reload value
  26          sfr16 TMR3     = 0xCC;                 // Timer3 counter
  27          
  28          //------------------------------------------------------------------------------------
  29          // Global CONSTANTS
  30          //------------------------------------------------------------------------------------
  31          
  32          #define SYSCLK 3062500                    // approximate SYSCLK frequency in Hz
  33          
  34          sbit  LED = P1^6;                         // green LED: '1' = ON; '0' = OFF
  35          
  36          //------------------------------------------------------------------------------------
  37          // Function PROTOTYPES
  38          //------------------------------------------------------------------------------------
  39          void PORT_Init (void);
  40          void Timer3_Init (int counts);
  41          void Timer3_ISR (void);
  42          
  43          //------------------------------------------------------------------------------------
  44          // MAIN Routine
  45          //------------------------------------------------------------------------------------
  46          void main (void) {
  47   1      
  48   1         // disable watchdog timer
  49   1         WDTCN = 0xde;
  50   1         WDTCN = 0xad;
  51   1      
  52   1         SFRPAGE = CONFIG_PAGE;                 // Switch to configuration page
  53   1         PORT_Init ();
  54   1      
  55   1         SFRPAGE = TMR3_PAGE;                   // Switch to Timer 3 page
C51 COMPILER V8.08   BLINKY                                                                06/17/2008 18:13:51 PAGE 2   

  56   1         Timer3_Init (SYSCLK / 12 / 10);        // Init Timer3 to generate interrupts
  57   1                                                // at a 10 Hz rate.
  58   1         EA = 1;                                                                                      // enable global interrupts
  59   1      
  60   1         SFRPAGE = LEGACY_PAGE;                 // Page to sit in for now
  61   1      
  62   1         while (1) {                            // spin forever
  63   2      
  64   2         }
  65   1      }
  66          
  67          //------------------------------------------------------------------------------------
  68          // PORT_Init
  69          //------------------------------------------------------------------------------------
  70          //
  71          // Configure the Crossbar and GPIO ports
  72          //
  73          void PORT_Init (void)
  74          {
  75   1         XBR2    = 0x40;                     // Enable crossbar and weak pull-ups
  76   1         P1MDOUT |= 0x40;                    // enable P1.6 (LED) as push-pull output
  77   1      }
  78          
  79          //------------------------------------------------------------------------------------
  80          // Timer3_Init
  81          //------------------------------------------------------------------------------------
  82          //
  83          // Configure Timer3 to auto-reload and generate an interrupt at interval
  84          // specified by <counts> using SYSCLK/12 as its time base.
  85          //
  86          //
  87          void Timer3_Init (int counts)
  88          {
  89   1         TMR3CN = 0x00;                      // Stop Timer3; Clear TF3;
  90   1                                             // use SYSCLK/12 as timebase
  91   1         RCAP3   = -counts;                  // Init reload values
  92   1         TMR3    = 0xffff;                   // set to reload immediately
  93   1         EIE2   |= 0x01;                     // enable Timer3 interrupts
  94   1         TR3 = 1;                            // start Timer3
  95   1      }
  96          
  97          //------------------------------------------------------------------------------------
  98          // Interrupt Service Routines
  99          //------------------------------------------------------------------------------------
 100          
 101          //------------------------------------------------------------------------------------
 102          // Timer3_ISR
 103          //------------------------------------------------------------------------------------
 104          // This routine changes the state of the LED whenever Timer3 overflows.
 105          //
 106          // NOTE: The SFRPAGE register will automatically be switched to the Timer 3 Page
 107          // When an interrupt occurs.  SFRPAGE will return to its previous setting on exit
 108          // from this routine.
 109          //
 110          void Timer3_ISR (void) interrupt 14
 111          {
 112   1         TF3 = 0;                               // clear TF3
 113   1         LED = ~LED;                            // change state of LED
 114   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
C51 COMPILER V8.08   BLINKY                                                                06/17/2008 18:13:51 PAGE 3   

   CODE SIZE        =     65    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   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 + -