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

📄 uart.lst

📁 LPC214X系列ARM在KEIL编译环境下的所以例程
💻 LST
📖 第 1 页 / 共 2 页
字号:
ARM COMPILER V2.53,  uart                                                                  02/08/06  09:01:33  PAGE 1   


ARM COMPILER V2.53, COMPILATION OF MODULE uart
OBJECT MODULE PLACED IN .\Obj\uart.obj
COMPILER INVOKED BY: g:\Keil\ARM\BIN\CA.exe uart.c THUMB INCDIR(..\Common\inc) DEBUG PRINT(.\LST\UART.LST) TABS(4) OBJEC
                    -T(.\Obj\uart.obj) 

stmt  level    source

    1          /*****************************************************************************
    2           *   uart.c:  UART API file for Philips LPC214x Family Microprocessors
    3           *
    4           *   Copyright(C) 2006, Philips Semiconductor
    5           *   All rights reserved.
    6           *
    7           *   History
    8           *   2005.10.01  ver 1.00    Prelimnary version, first Release
    9           *
   10          ******************************************************************************/
   11          #include "LPC214x.H"                        /* LPC21xx definitions */
   12          #include "type.h"
   13          #include "target.h"
   14          #include "irq.h"
   15          #include "uart.h"
   16          
   17          DWORD UART0Status;
   18          BYTE UART0TxEmpty = 1;
   19          BYTE UART0Buffer[BUFSIZE]={0x01,0x03,0x05,0x07,0x09,0x0a,0x0b,0x0c,0x08,0x04};
   20          DWORD UART0Count = 0;
   21          
   22          /*****************************************************************************
   23          ** Function name:       UART0Handler
   24          **
   25          ** Descriptions:        UART0 interrupt handler
   26          **
   27          ** parameters:          None
   28          ** Returned value:      None
   29          ** 
   30          *****************************************************************************/
   31          void UART0Handler (void) __irq 
   32          {
   33   1          BYTE IIRValue, LSRValue;
   34   1          BYTE Dummy;
   35   1      
   36   1          IENABLE;                /* handles nested interrupt */  
   37   1          IIRValue = U0IIR;
   38   1          
   39   1          IIRValue >>= 1;         /* skip pending bit in IIR */
   40   1          IIRValue &= 0x07;           /* check bit 1~3, interrupt identification */
   41   1          if ( IIRValue == IIR_RLS )      /* Receive Line Status */
   42   1          {
   43   2          LSRValue = U0LSR;
   44   2          /* Receive Line Status */
   45   2          if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
   46   2          {
   47   3              /* There are errors or break interrupt */
   48   3              /* Read LSR will clear the interrupt */
   49   3              UART0Status = LSRValue;
   50   3              Dummy = U0RBR;      /* Dummy read on RX to clear 
   51   3                          interrupt, then bail out */
   52   3              IDISABLE;
   53   3              VICVectAddr = 0;        /* Acknowledge Interrupt */
   54   3              return;
   55   3          }
   56   2          if ( LSRValue & LSR_RDR )   /* Receive Data Ready */            
   57   2          {
   58   3              /* If no error on RLS, normal ready, save into the data buffer. */
ARM COMPILER V2.53,  uart                                                                  02/08/06  09:01:33  PAGE 2   

   59   3              /* Note: read RBR will clear the interrupt */
   60   3              UART0Buffer[UART0Count] = U0RBR;
   61   3              UART0Count++;
   62   3              if ( UART0Count == BUFSIZE )
   63   3              {
   64   4              UART0Count = 0;     /* buffer overflow */
   65   4              }   
   66   3          }
   67   2          }
   68   1          else if ( IIRValue == IIR_RDA ) /* Receive Data Available */
   69   1          {
   70   2          /* Receive Data Available */
   71   2          UART0Buffer[UART0Count] = U0RBR;
   72   2          UART0Count++;
   73   2          if ( UART0Count == BUFSIZE )
   74   2          {
   75   3              UART0Count = 0;     /* buffer overflow */
   76   3          }
   77   2          }
   78   1          else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */
   79   1          {
   80   2          /* Character Time-out indicator */
   81   2          UART0Status |= 0x100;       /* Bit 9 as the CTI error */
   82   2          }
   83   1          else if ( IIRValue == IIR_THRE )    /* THRE, transmit holding register empty */
   84   1          {
   85   2          /* THRE interrupt */
   86   2          LSRValue = U0LSR;       /* Check status in the LSR to see if
   87   2                          valid data in U0THR or not */
   88   2          if ( LSRValue & LSR_THRE )
   89   2          {
   90   3              UART0TxEmpty = 1;
   91   3          }
   92   2          else
   93   2          {
   94   3              UART0TxEmpty = 0;
   95   3          }
   96   2          }
   97   1          
   98   1          IDISABLE;
   99   1          VICVectAddr = 0;        /* Acknowledge Interrupt */
  100   1      }
  101          
  102          /*****************************************************************************
  103          ** 函数名:      UARTInit
  104          **
  105          ** 描述:        初始化UART0端口, 选择引脚设置,
  106          **              时钟, 奇偶, 停止位, FIFO,等等.
  107          **
  108          ** 参数:            UART 波特率
  109          ** 返回值:      true or false, return false only if the 
  110          **              interrupt handler can't be installed to the 
  111          **              VIC table
  112          ** 
  113          *****************************************************************************/
  114          DWORD UARTInit( DWORD baudrate )
  115          {
  116   1          DWORD Fdiv;
  117   1      
  118   1          PINSEL0 = 0x00050005;       /* 允许 RxD1 和TxD1, RxD0 和TxD0 */
  119   1      
  120   1          U0LCR = 0x83;               /* 8 位,无奇偶校验, 一位停止位   */
  121   1          Fdiv = ( Fpclk / 16 ) / baudrate ;  /*波特率 */
  122   1          U0DLM = Fdiv / 256;                         
  123   1          U0DLL = Fdiv % 256; 
  124   1          U0LCR = 0x03;               /* DLAB = 0                         */
ARM COMPILER V2.53,  uart                                                                  02/08/06  09:01:33  PAGE 3   

  125   1          U0FCR = 0x07;       /* 允许复位 TX 和RX FIFO. */
  126   1      
  127   1          if ( install_irq( UART0_INT, (void *)UART0Handler ) == FALSE )
  128   1          {
  129   2          return (FALSE);
  130   2          }
  131   1         
  132   1          U0IER = IER_RBR | IER_THRE | IER_RLS;   /* 允许UART0中断*/
  133   1          return (TRUE);
  134   1      }
  135          
  136          /*****************************************************************************
  137          ** Function name:       UARTSend
  138          **
  139          ** Descriptions:        Send a block of data to the UART 0 port based
  140          **              on the data length
  141          **
  142          ** 参数:            缓冲器指示, a和数据长度
  143          ** Returned value:      None
  144          ** 
  145          *****************************************************************************/
  146          void UARTSend(BYTE *BufferPtr, DWORD Length )
  147          {
  148   1          while ( Length != 0 )
  149   1          {
  150   2          while ( !(UART0TxEmpty & 0x01) );   /* THRE status, contain valid 
  151   2                              data */
  152   2          U0THR = *BufferPtr;
  153   2          UART0TxEmpty = 0;   /* not empty in the THR until it shifts out */
  154   2          BufferPtr++;
  155   2          Length--;
  156   2          }
  157   1          return;
  158   1      }
  159          
  160          /******************************************************************************
  161          **                            End Of File
  162          ******************************************************************************/
ARM COMPILER V2.53,  uart                                                                  02/08/06  09:01:33  PAGE 4   

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN CODE16 (install_irq?T)
 EXTERN CODE16 (?C?UDIV?T)



*** PUBLICS:
 PUBLIC         UARTInit?T
 PUBLIC         UART0Handler?A
 PUBLIC         UARTSend?T
 PUBLIC         UART0Status
 PUBLIC         UART0TxEmpty
 PUBLIC         UART0Buffer
 PUBLIC         UART0Count



*** DATA SEGMENT '?DT0?uart':
 00000000          UART0Status:
 00000000            DS          4
 00000004          UART0Count:
 00000004           BEGIN_INIT
 00000004  00000000  DD          0x0
 00000008           END_INIT
 00000008          UART0TxEmpty:
 00000008           BEGIN_INIT
 00000008  01        DB          0x1
 00000009           END_INIT
 00000009          UART0Buffer:
 00000009           BEGIN_INIT
 00000009  01        DB          0x1
 0000000A  03        DB          0x3
 0000000B  05        DB          0x5
 0000000C  07        DB          0x7
 0000000D  09        DB          0x9
 0000000E  0A        DB          0xA
 0000000F  0B        DB          0xB
 00000010  0C        DB          0xC
 00000011  08        DB          0x8
 00000012  04        DB          0x4
 00000013            SPACE       6
 00000019           END_INIT



*** CODE SEGMENT '?PR?UART0Handler?A?uart':
   31: void UART0Handler (void) __irq 
 00000000  E92D403F  STMDB       R13!,{R0-R5,LR}
 00000004  ---- Variable 'LSRValue' assigned to Register 'R0' ----
   32: {
 00000004            ; SCOPE-START
   36:     IENABLE;                /* handles nested interrupt */  
 00000004  E14FE000  MRS         R14,SPSR
 00000008  E92D4000  STMFD       R13!,{LR}
 0000000C  E321F01F  MSR         CPSR_c,#0x1F
 00000010  E92D4000  STMFD       R13!,{LR}
   37:     IIRValue = U0IIR;
 00000014  E5101000  LDR         R1,=0xE000C008
 00000018  E5912000  LDR         R2,[R1,#0x0]
 0000001C  E1A02C02  MOV         R2,R2,LSL #24
 00000020  E1A02C22  MOV         R2,R2,LSR #24
 00000024  ---- Variable 'IIRValue' assigned to Register 'R2' ----
   39:     IIRValue >>= 1;         /* skip pending bit in IIR */
 00000024  E1A020A2  MOV         R2,R2,LSR #1 ; IIRValue
   40:     IIRValue &= 0x07;           /* check bit 1~3, interrupt identification */
 00000028  E2022007  AND         R2,R2,#0x0007 ; IIRValue
   41:     if ( IIRValue == IIR_RLS )      /* Receive Line Status */
 0000002C  E1A01002  MOV         R1,R2 ; IIRValue
 00000030  E1A01C01  MOV         R1,R1,LSL #24 ; IIRValue
ARM COMPILER V2.53,  uart                                                                  02/08/06  09:01:33  PAGE 5   

 00000034  E1A01C21  MOV         R1,R1,LSR #24
 00000038  E3510003  CMP         R1,#0x0003
 0000003C  1A000030  BNE         L_1  ; Targ=0x104
   43:     LSRValue = U0LSR;
 00000040  E5100000  LDR         R0,=0xE000C014
 00000044  E5900000  LDR         R0,[R0,#0x0]
 00000048  E1A00C00  MOV         R0,R0,LSL #24
 0000004C  E1A00C20  MOV         R0,R0,LSR #24
   45:     if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
 00000050  E1A01000  MOV         R1,R0 ; LSRValue
 00000054  E1A01C01  MOV         R1,R1,LSL #24 ; LSRValue
 00000058  E1A01C21  MOV         R1,R1,LSR #24
 0000005C  E311009E  TST         R1,#0x009E
 00000060  0A00000E  BEQ         L_2  ; Targ=0xA0
   49:         UART0Status = LSRValue;
 00000064  E1A01000  MOV         R1,R0 ; LSRValue
 00000068  E1A03C01  MOV         R3,R1,LSL #24 ; LSRValue

⌨️ 快捷键说明

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