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

📄 f12x_init.lst

📁 cf8020+cp2200(网络)的驱动实现
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.09   F12X_INIT                                                             06/29/2007 17:12:09 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE F12X_INIT
OBJECT MODULE PLACED IN F12x_Init.OBJ
COMPILER INVOKED BY: F:\Keil\C51\BIN\C51.EXE F12x_Init.c LARGE BROWSE DEBUG OBJECTEXTEND

line level    source

   1          //-----------------------------------------------------------------------------
   2          // F12x_Init.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2006 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          // 
   9          // Contains Initialization Routines for the F120.
  10          //
  11          // FID:            
  12          // Target:         C8051F12x
  13          // Tool chain:     Keil C51 7.20 / Keil EVAL C51
  14          //                 Silicon Laboratories IDE version 2.72 
  15          // Command Line:   See Readme.txt
  16          // Project Name:   CP220x_Ethernet_Routines
  17          //
  18          // 
  19          //
  20          // Release 1.1
  21          //    - Configures C8051F120 SYSCLK to 98 MHz
  22          //
  23          // Release 1.0
  24          //    -Initial Release (FB)
  25          //    -30 MAY 2006
  26          //
  27          
  28          //-----------------------------------------------------------------------------
  29          // Includes
  30          //-----------------------------------------------------------------------------
  31          #include "global.h"
  32          
  33          #if(MCU == F020)
  34          
  35          //-----------------------------------------------------------------------------
  36          // 16-bit SFR Definitions for 'F12x
  37          //-----------------------------------------------------------------------------
  38          
  39          sfr16 DP       = 0x82;                 // data pointer
  40          sfr16 ADC0     = 0xbe;                 // ADC0 data
  41          sfr16 ADC0GT   = 0xc4;                 // ADC0 greater than window
  42          sfr16 ADC0LT   = 0xc6;                 // ADC0 less than window
  43          sfr16 RCAP2    = 0xca;                 // Timer2 capture/reload
  44          sfr16 RCAP3    = 0xca;                 // Timer3 capture/reload
  45          sfr16 RCAP4    = 0xca;                 // Timer4 capture/reload
  46          sfr16 TMR2     = 0xcc;                 // Timer2
  47          sfr16 TMR3     = 0xcc;                 // Timer3
  48          sfr16 TMR4     = 0xcc;                 // Timer4
  49          sfr16 DAC0     = 0xd2;                 // DAC0 data
  50          sfr16 DAC1     = 0xd2;                 // DAC1 data
  51          sfr16 PCA0CP5  = 0xe1;                 // PCA0 Module 5 capture
  52          sfr16 PCA0CP2  = 0xe9;                 // PCA0 Module 2 capture
  53          sfr16 PCA0CP3  = 0xeb;                 // PCA0 Module 3 capture
  54          sfr16 PCA0CP4  = 0xed;                 // PCA0 Module 4 capture
  55          sfr16 PCA0     = 0xf9;                 // PCA0 counter
C51 COMPILER V7.09   F12X_INIT                                                             06/29/2007 17:12:09 PAGE 2   

  56          sfr16 PCA0CP0  = 0xfb;                 // PCA0 Module 0 capture
  57          sfr16 PCA0CP1  = 0xfd;                 // PCA0 Module 1 capture
  58          
  59          //-----------------------------------------------------------------------------
  60          // Local Constants
  61          //-----------------------------------------------------------------------------
  62          #define SYSCLK  73500000               // System Clock in Hz
  63          
  64          
  65          //-----------------------------------------------------------------------------
  66          // Local Global Variables 
  67          //-----------------------------------------------------------------------------
  68          
  69          static unsigned int timeout;
  70          
  71          //-----------------------------------------------------------------------------
  72          // Exported Function Prototypes
  73          //-----------------------------------------------------------------------------
  74          void Reset_Init(void);
  75          
  76          void wait_ms(int ms);
  77          void clear_ms_timer_flag(void);
  78          char get_ms_timer_flag(void);
  79          void start_ms_timer();
  80          
  81          void CP220x_RST_Low(void);
  82          void CP220x_RST_High(void);
  83          unsigned char AB4_RST_State(void);
  84          
  85          #if(UART_ENABLED)
              char _getkey ();
              char putchar (char c);
              #endif
  89          
  90          //-----------------------------------------------------------------------------
  91          // Local Function Prototypes
  92          //-----------------------------------------------------------------------------
  93          
  94          void PORT_Init (void);
  95          void SYSCLK_Init (void);
  96          void EMIF_Init (void);
  97          
  98          #if(UART_ENABLED)
              void UART1_Init (void);
              #endif
 101          
 102          //-----------------------------------------------------------------------------
 103          // Exported Functions
 104          //-----------------------------------------------------------------------------
 105          
 106          //-----------------------------------------------------------------------------
 107          // Reset_Init
 108          //-----------------------------------------------------------------------------
 109          void Reset_Init(void)
 110          {
 111   1         // Enable the VDD Monitor as a reset source
 112   1         // Do not use read-modify write instruction on this register
 113   1       //  RSTSRC = 0x02;
 114   1      
 115   1         // Disable Watchdog Timer
 116   1         WDTCN = 0xde;
 117   1         WDTCN = 0xad;
C51 COMPILER V7.09   F12X_INIT                                                             06/29/2007 17:12:09 PAGE 3   

 118   1      
 119   1         // Initialize the MCU
 120   1         PORT_Init();
 121   1         SYSCLK_Init();
 122   1         EMIF_Init();
 123   1      
 124   1         EX0 = 1;                            // Enable External Interrupt 0   
 125   1      
 126   1         #if(UART_ENABLED)
                 UART1_Init();
                 puts("\n*** Reset ***\nC8051F12x MCU Initialized\n");
                 #endif
 130   1      
 131   1      }
 132          
 133          //-----------------------------------------------------------------------------
 134          // External Interrupt 0
 135          //-----------------------------------------------------------------------------
 136          //
 137          // This interrupt service routine is routed to the ethernet interrupt
 138          //
 139          void INT0_ISR(void) interrupt 0
 140          {
 141   1         Ethernet_ISR();
 142   1      }
 143          
 144          
 145          //-----------------------------------------------------------------------------
 146          // wait_ms
 147          //-----------------------------------------------------------------------------
 148          //
 149          // This routine inserts a delay of <ms> milliseconds.
 150          //
 151          void wait_ms(int ms)
 152          {
 153   1         char SFRPAGE_SAVE = SFRPAGE;        // Save Current SFR page
*** ERROR C202 IN LINE 153 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 154   1      
 155   1         SFRPAGE = TMR2_PAGE;
*** ERROR C202 IN LINE 155 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 156   1      
 157   1         TMR2CN = 0x00;                      // Stop Timer2; Clear TF2;
*** ERROR C202 IN LINE 157 OF F12X_INIT.C: 'TMR2CN': undefined identifier
 158   1         TMR2CF = 0x00;                      // use SYSCLK/12 as timebase
*** ERROR C202 IN LINE 158 OF F12X_INIT.C: 'TMR2CF': undefined identifier
 159   1      
 160   1         RCAP2 = -(SYSCLK/1000/12);          // Timer 2 overflows at 1 kHz
 161   1         TMR2 = RCAP2;
 162   1      
 163   1         ET2 = 0;                            // Disable Timer 2 interrupts
 164   1      
 165   1         TR2 = 1;                            // Start Timer 2
 166   1      
 167   1         while(ms){
 168   2            TF2 = 0;
 169   2            while(!TF2);                     // wait until timer overflows
 170   2            ms--;                            // decrement ms
 171   2         }
 172   1      
 173   1         TR2 = 0;                            // Stop Timer 2
 174   1      
 175   1         SFRPAGE = SFRPAGE_SAVE;             // Restore SFRPAGE
C51 COMPILER V7.09   F12X_INIT                                                             06/29/2007 17:12:09 PAGE 4   

*** ERROR C202 IN LINE 175 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 176   1      }
 177          
 178          //-----------------------------------------------------------------------------
 179          // reset_timout
 180          //-----------------------------------------------------------------------------
 181          //
 182          // This routine resets the global timeout.
 183          //
 184          void reset_timeout(unsigned int ms)
 185          {
 186   1         timeout = ms;
 187   1         start_ms_timer();
 188   1            
 189   1      }
 190          
 191          
 192          //-----------------------------------------------------------------------------
 193          // timeout_expired
 194          //-----------------------------------------------------------------------------
 195          //
 196          // This routine manages the timeout and returns TRUE if timeout expired.
 197          //
 198          unsigned char timeout_expired(void)
 199          {
 200   1         if(get_ms_timer_flag()){
 201   2            clear_ms_timer_flag();
 202   2            if(timeout > 0){
 203   3               timeout--;
 204   3            }
 205   2         }
 206   1         
 207   1         return (timeout == 0);
 208   1           
 209   1         
 210   1      }
 211          //-----------------------------------------------------------------------------
 212          // start_ms_timer
 213          //-----------------------------------------------------------------------------
 214          //
 215          // This routine starts a timer with a 1kHz overflow rate (1ms period).
 216          //
 217          void start_ms_timer()
 218          {
 219   1         char SFRPAGE_SAVE = SFRPAGE;        // Save Current SFR page
*** ERROR C202 IN LINE 219 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 220   1      
 221   1         SFRPAGE = TMR2_PAGE;
*** ERROR C202 IN LINE 221 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 222   1      
 223   1         TMR2CN = 0x00;                      // Stop Timer2; Clear TF2;
*** ERROR C202 IN LINE 223 OF F12X_INIT.C: 'TMR2CN': undefined identifier
 224   1         TMR2CF = 0x00;                      // use SYSCLK/12 as timebase
*** ERROR C202 IN LINE 224 OF F12X_INIT.C: 'TMR2CF': undefined identifier
 225   1      
 226   1         RCAP2 = -(SYSCLK/1000/12);          // Timer 2 overflows at 1 kHz
 227   1         TMR2 = RCAP2;
 228   1      
 229   1         ET2 = 0;                            // Disable Timer 2 interrupts
 230   1      
 231   1         TR2 = 1;                            // Start Timer 2
 232   1      
C51 COMPILER V7.09   F12X_INIT                                                             06/29/2007 17:12:09 PAGE 5   

 233   1         SFRPAGE = SFRPAGE_SAVE;             // Restore SFRPAGE
*** ERROR C202 IN LINE 233 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 234   1      }
 235          
 236          //-----------------------------------------------------------------------------
 237          // get_ms_timer_flag()
 238          //-----------------------------------------------------------------------------
 239          //
 240          // This routine returns the state of the ms_timer overflow flag.
 241          //
 242          char get_ms_timer_flag(void)
 243          {
 244   1         char SFRPAGE_SAVE = SFRPAGE;        // Save Current SFR page
*** ERROR C202 IN LINE 244 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 245   1      
 246   1         SFRPAGE = TMR2_PAGE;
*** ERROR C202 IN LINE 246 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 247   1      
 248   1         return TF2;
 249   1      
 250   1         SFRPAGE = SFRPAGE_SAVE;             // Restore SFRPAGE
*** ERROR C202 IN LINE 250 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 251   1      }
 252          
 253          //-----------------------------------------------------------------------------
 254          // clear_ms_timer_flag()
 255          //-----------------------------------------------------------------------------
 256          //
 257          // This routine returns the state of the ms_timer overflow flag.
 258          //
 259          void clear_ms_timer_flag(void)
 260          {
 261   1         char SFRPAGE_SAVE = SFRPAGE;        // Save Current SFR page
*** ERROR C202 IN LINE 261 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 262   1      
 263   1         SFRPAGE = TMR2_PAGE;
*** ERROR C202 IN LINE 263 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 264   1      
 265   1         TF2 = 0;
 266   1      
 267   1         SFRPAGE = SFRPAGE_SAVE;             // Restore SFRPAGE
*** ERROR C202 IN LINE 267 OF F12X_INIT.C: 'SFRPAGE': undefined identifier
 268   1      }
 269          
 270          

⌨️ 快捷键说明

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