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

📄 uart.lst

📁 矿工定位系统单端
💻 LST
字号:
C51 COMPILER V7.05   UART                                                                  04/13/2004 13:35:27 PAGE 1   


C51 COMPILER V7.05, COMPILATION OF MODULE UART
OBJECT MODULE PLACED IN uart.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE uart.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //uart.c - code recommendation for C header file
   2          /***********************************************************************
   3          MODULE:    UART
   4          VERSION:   1.04
   5          CONTAINS:  Routines for controlling the UART peripheral on the Philips
   6                     P89LPC932
   7          COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
   8          LICENSE:   May be freely used in commercial and non-commercial code
   9                     without royalties provided this copyright notice remains
  10                     in this file and unaltered
  11          WARNING:   IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
  12                     MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
  13                     TO CHANGE THE CONTENTS OF THIS FILE
  14          GENERATED: On "Feb 24 2004" at "11:46:47" by Code Architect 2.03
  15          ***********************************************************************/
  16          
  17          // SFR description needs to be included
  18          #include<REG922.h>
  19          #include "uart.h"
  20          
  21          // flag that indicates if the UART is busy transmitting or not
  22          static bit mtxbusy;
  23          
  24          /***********************************************************************
  25          DESC:    Initializes UART for mode 1
  26                   Baudrate: 19200
  27          RETURNS: Nothing
  28          CAUTION: If interrupts are being used then EA must be set to 1
  29                   after calling this function
  30          ************************************************************************/
  31          void user_uart_init(void)
  32          {
  33   1        // configure UART
  34   1        // clear SMOD0
  35   1        PCON &= ~0x40;
  36   1        SCON = 0x50;
  37   1        // set or clear SMOD1
  38   1        PCON &= 0x7f;
  39   1        PCON |= (0 << 8);
  40   1        SSTAT = 0x00;
  41   1      
  42   1        // configure baud rate generator
  43   1        BRGCON = 0x00;
  44   1        BRGR0 = 0x70;  //19200
  45   1        BRGR1 = 0x01;
  46   1      
  47   1        //BRGR0 = 0xF0;   //9600
  48   1       // BRGR1 = 0x02;
  49   1      
  50   1        BRGCON = 0x03;
  51   1      
  52   1        // TxD = push-pull, RxD = input
  53   1        P1M1 &= ~0x01;
  54   1        P1M2 |= 0x01;
  55   1        P1M1 |= 0x02;
C51 COMPILER V7.05   UART                                                                  04/13/2004 13:35:27 PAGE 2   

  56   1        P1M2 &= ~0x02;
  57   1      
  58   1        // initially not busy
  59   1        mtxbusy = 0;
  60   1      
  61   1        // set isr priority to 0
  62   1        IP0 &= 0xEF;
  63   1        IP0H &= 0xEF;
  64   1        // enable uart interrupt
  65   1        AUXR1 &= 0xbf;
  66   1        ES = 1;
  67   1      
  68   1      } // user_uart_init
  69          
  70          
  71          /***********************************************************************
  72          DESC:    Transmits a 8-bit value via the UART in the current mode
  73                   May result in a transmit interrupt if enabled.
  74          RETURNS: Nothing
  75          CAUTION: user_uart_init must be called first
  76          ************************************************************************/
  77          void uart_transmit(unsigned char value )  // data to transmit
  78          {
  79   1        while(mtxbusy);
  80   1        mtxbusy = 1;
  81   1        SBUF = value;
  82   1      } // uart_transmit
  83          
  84          /***********************************************************************
  85          DESC:    Gets a received 8-bit value from the UART
  86          RETURNS: Received data
  87          CAUTION: user_uart_init must be called first
  88          ************************************************************************/
  89          unsigned char uart_get (void)
  90          {
  91   1        return SBUF;
  92   1      } // uart_get
  93          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =     60    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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