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

📄 f02x_uart1_interrupt.lst

📁 基于单片机c8051F020的串行口通信的源程序代码。
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   F02X_UART1_INTERRUPT                                                  04/18/2009 11:16:42 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE F02X_UART1_INTERRUPT
OBJECT MODULE PLACED IN F02x_UART1_Interrupt.OBJ
COMPILER INVOKED BY: D:\keil 7.06\C51\BIN\C51.EXE F02x_UART1_Interrupt.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // F02x_UART1_Interrupt.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2006 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          //
   9          // This program demonstrates how to configure the C8051F020 to write to and read
  10          // from the UART interface. The program reads a word using the UART1 interrupts
  11          // and outputs that word to the screen, with all characters in uppercase
  12          //
  13          // How To Test:
  14          //
  15          // 1) Download code to a 'F02x device that is connected to a UART transceiver
  16          // 2) Verify jumpers J6 and J9 are populated on the 'F02x TB.
  17          // 3) Connect serial cable from the transceiver to a PC
  18          // 4) On the PC, open HyperTerminal (or any other terminal program) and connect
  19          //    to the COM port at <BAUDRATE> and 8-N-1
  20          // 5) Download and execute code on an 'F02x target board.
  21          //
  22          //
  23          // Target:         C8051F02x
  24          // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  25          // Command Line:   None
  26          //
  27          // Release 1.0
  28          //    -Initial Revision (SM)
  29          //    -6 JUN 2007
  30          //
  31          //
  32          //-----------------------------------------------------------------------------
  33          // Includes
  34          //-----------------------------------------------------------------------------
  35          
  36          #include <c8051f020.h>                 // SFR declarations
*** WARNING C318 IN LINE 36 OF F02x_UART1_Interrupt.c: can't open file 'c8051f020.h'
  37          #include <stdio.h>
  38          
  39          //-----------------------------------------------------------------------------
  40          // 16-bit SFR Definitions for 'F02x
  41          //-----------------------------------------------------------------------------
  42          
  43          sfr16 RCAP2    = 0xca;                 // Timer2 capture/reload
  44          sfr16 TMR2     = 0xcc;                 // Timer2
  45          
  46          //-----------------------------------------------------------------------------
  47          // Global Constants
  48          //-----------------------------------------------------------------------------
  49          
  50          #define BAUDRATE     115200            // Baud rate of UART in bps
  51          
  52          // SYSTEMCLOCK = System clock frequency in Hz
  53          
  54          #define SYSTEMCLOCK       (22118400L)
C51 COMPILER V7.06   F02X_UART1_INTERRUPT                                                  04/18/2009 11:16:42 PAGE 2   

  55          
  56          //-----------------------------------------------------------------------------
  57          // Function Prototypes
  58          //-----------------------------------------------------------------------------
  59          
  60          void OSCILLATOR_Init (void);
  61          void PORT_Init (void);
  62          void UART1_Init (void);
  63          
  64          //-----------------------------------------------------------------------------
  65          // Global Variables
  66          //-----------------------------------------------------------------------------
  67          
  68          #define UART_BUFFERSIZE 64
  69          unsigned char UART_Buffer[UART_BUFFERSIZE];
  70          unsigned char UART_Buffer_Size = 0;
  71          unsigned char UART_Input_First = 0;
  72          unsigned char UART_Output_First = 0;
  73          unsigned char TX_Ready =1;
  74          static char Byte;
  75          
  76          //-----------------------------------------------------------------------------
  77          // main() Routine
  78          //-----------------------------------------------------------------------------
  79          
  80          void main (void)
  81          {
  82   1         WDTCN = 0xde;                       // Disable watchdog timer
*** ERROR C202 IN LINE 82 OF F02X_UART1_INTERRUPT.C: 'WDTCN': undefined identifier
  83   1         WDTCN = 0xad;
*** ERROR C202 IN LINE 83 OF F02X_UART1_INTERRUPT.C: 'WDTCN': undefined identifier
  84   1      
  85   1         OSCILLATOR_Init ();                 // Initialize oscillator
  86   1         PORT_Init ();                       // Initialize crossbar and GPIO
  87   1      
  88   1         UART1_Init ();                      // Initialize UART1
  89   1      
  90   1         EA = 1;
*** ERROR C202 IN LINE 90 OF F02X_UART1_INTERRUPT.C: 'EA': undefined identifier
  91   1         while (1)
  92   1         {
  93   2            // If the complete word has been entered via the hyperterminal followed by
  94   2            // carriage return
  95   2            if((TX_Ready == 1) && (UART_Buffer_Size != 0) && (Byte == 13))
  96   2            {
  97   3               TX_Ready = 0;                  // Set the flag to zero
  98   3               SCON1 = (SCON1 | 0x02);        // Set transmit flag to 1
*** ERROR C202 IN LINE 98 OF F02X_UART1_INTERRUPT.C: 'SCON1': undefined identifier
  99   3      
 100   3            }
 101   2         }
 102   1      }
 103          
 104          //-----------------------------------------------------------------------------
 105          // Initialization Subroutines
 106          //-----------------------------------------------------------------------------
 107          
 108          //-----------------------------------------------------------------------------
 109          // OSCILLATOR_Init
 110          //-----------------------------------------------------------------------------
 111          //
 112          // Return Value : None
C51 COMPILER V7.06   F02X_UART1_INTERRUPT                                                  04/18/2009 11:16:42 PAGE 3   

 113          // Parameters   : None
 114          //
 115          // This function initializes the system clock to use the  external 22.1184MHz
 116          // crystal.
 117          //
 118          //-----------------------------------------------------------------------------
 119          void OSCILLATOR_Init (void)
 120          {
 121   1         int i;                              // Software timer
 122   1      
 123   1         OSCICN |= 0x80;                     // Enable the missing clock detector
*** ERROR C202 IN LINE 123 OF F02X_UART1_INTERRUPT.C: 'OSCICN': undefined identifier
 124   1      
 125   1         // Initialize external crystal oscillator to use 22.1184 MHz crystal
 126   1      
 127   1         OSCXCN = 0x67;                      // Enable external crystal osc.
*** ERROR C202 IN LINE 127 OF F02X_UART1_INTERRUPT.C: 'OSCXCN': undefined identifier
 128   1         for (i=0; i < 256; i++);            // Wait at least 1ms
 129   1         while (!(OSCXCN & 0x80));           // Wait for crystal osc to settle
*** ERROR C202 IN LINE 129 OF F02X_UART1_INTERRUPT.C: 'OSCXCN': undefined identifier
 130   1         OSCICN |= 0x08;                     // Select external clock source
*** ERROR C202 IN LINE 130 OF F02X_UART1_INTERRUPT.C: 'OSCICN': undefined identifier
 131   1         OSCICN &= ~0x04;                    // Disable the internal osc.
*** ERROR C202 IN LINE 131 OF F02X_UART1_INTERRUPT.C: 'OSCICN': undefined identifier
 132   1      }
 133          
 134          //-----------------------------------------------------------------------------
 135          // PORT_Init
 136          //-----------------------------------------------------------------------------
 137          //
 138          // Return Value : None
 139          // Parameters   : None
 140          //
 141          // This function configures the crossbar and GPIO ports.
 142          //
 143          // P0.0   digital   push-pull     UART TX
 144          // P0.1   digital   open-drain    UART RX
 145          //-----------------------------------------------------------------------------
 146          void PORT_Init (void)
 147          {
 148   1         XBR0     = 0x00;
*** ERROR C202 IN LINE 148 OF F02X_UART1_INTERRUPT.C: 'XBR0': undefined identifier
 149   1         XBR1     = 0x00;

⌨️ 快捷键说明

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