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

📄 timerdemo.lst

📁 TIMERDEMO for arm7 ,学习用
💻 LST
📖 第 1 页 / 共 2 页
字号:
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 1   


ARM COMPILER V2.42, COMPILATION OF MODULE TIMERDEMO
OBJECT MODULE PLACED IN TIMERDEMO.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe TIMERDEMO.c THUMB BROWSE DEBUG TABS(4) 

stmt  level    source

    1          #include <LPC213x.H>    // Philips Peripheral Registers
    2          #include <LPC213xDEF.H> //ARM菜鸟HotPower创建定义文件
    3          /*----------------------------------------------------
    4          文   件   名:  LPC213XDEF.H
    5          创   建   人:  ARM菜鸟  HotPower@126.com
    6          创 建 日  期:  2005.7.23   0:38
    7          最近修改日期:  2006.1.11   2:38
    8          创 建 地 点 : 西安大雁塔村队部
    9          说       明 : 已经过硬件调试
   10          实 验 项 目 : 蜂鸣器实验
   11          ------------------------------------------------------*/
   12          
   13          /*-----------------------------------------
   14                   LED数码字符定义
   15          -------------------------------------------*/
   16          
   17          //共阳极数码管(左移)
   18          
   19          #define LedSegA  0x01
   20          #define LedSegB  0x02
   21          #define LedSegC  0x04
   22          #define LedSegD  0x08
   23          #define LedSegE  0x10
   24          #define LedSegF  0x20
   25          #define LedSegG  0x40
   26          #define LedSegH  0x80
   27          
   28          //
   29          
   30          //共阳极数码管(右移)
   31          /*
   32          #define LedSegA  0x80
   33          #define LedSegB  0x40
   34          #define LedSegC  0x20
   35          #define LedSegD  0x10
   36          #define LedSegE  0x08
   37          #define LedSegF  0x04
   38          #define LedSegG  0x02
   39          #define LedSegH  0x01
   40          */
   41          //
   42          
   43          #define LedChar0 (LedSegA + LedSegB + LedSegC + LedSegD + LedSegE + LedSegF          )
   44          #define LedChar1 (          LedSegB + LedSegC                                        )
   45          #define LedChar2 (LedSegA + LedSegB           + LedSegD + LedSegE           + LedSegG)
   46          #define LedChar3 (LedSegA + LedSegB + LedSegC + LedSegD                     + LedSegG)
   47          #define LedChar4 (          LedSegB + LedSegC                     + LedSegF + LedSegG)
   48          #define LedChar5 (LedSegA           + LedSegC + LedSegD           + LedSegF + LedSegG)
   49          #define LedChar6 (LedSegA           + LedSegC + LedSegD + LedSegE + LedSegF + LedSegG)
   50          #define LedChar7 (LedSegA + LedSegB + LedSegC                                        )
   51          #define LedChar8 (LedSegA + LedSegB + LedSegC + LedSegD + LedSegE + LedSegF + LedSegG)
   52          #define LedChar9 (LedSegA + LedSegB + LedSegC + LedSegD           + LedSegF + LedSegG)
   53          #define LedCharA (LedSegA + LedSegB + LedSegC           + LedSegE + LedSegF + LedSegG)
   54          #define LedCharB (                    LedSegC + LedSegD + LedSegE + LedSegF + LedSegG)
   55          #define LedCharC (LedSegA                     + LedSegD + LedSegE + LedSegF          )
   56          #define LedCharD (          LedSegB + LedSegC + LedSegD + LedSegE           + LedSegG)
   57          #define LedCharE (LedSegA                     + LedSegD + LedSegE + LedSegF + LedSegG)
   58          #define LedCharF (LedSegA                               + LedSegE + LedSegF + LedSegG)
   59          
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 2   

   60          static const unsigned char LedTab[] =
   61          {
   62            ~LedChar0,
   63            ~LedChar1,
   64            ~LedChar2,
   65            ~LedChar3,
   66            ~LedChar4,
   67            ~LedChar5,
   68            ~LedChar6,
   69            ~LedChar7,
   70            ~LedChar8,
   71            ~LedChar9,
   72            ~LedCharA,
   73            ~LedCharB,
   74            ~LedCharC,
   75            ~LedCharD,
   76            ~LedCharE,
   77            ~LedCharF
   78          };
   79          
   80          #define RCLK    P0_29
   81          //#define SCK0  P0_28  //<LPC213xDEF.H>已定义
   82          //#define MOSI0 P0_25  //<LPC213xDEF.H>已定义
   83          #define BEEP    P0_7// P0.7控制蜂鸣器,低电平蜂鸣
   84          
   85          
   86          
   87          
   88          #define LED1    P1_18//
   89          #define LED2    P1_19//
   90          #define LED3    P1_20//
   91          #define LED4    P1_21//
   92          #define LED5    P1_22//
   93          #define LED6    P1_23//
   94          #define LED7    P1_24//
   95          #define LED8    P1_25//
   96          
   97          /* System configuration .Fosc、Fcclk、Fcco、Fpclk must be defined */
   98          /* 系统设置, Fosc、Fcclk、Fcco、Fpclk必须定义*/
   99          #define Fosc            11059200                    //Crystal frequence,10MHz~25MHz,should be the same a
             -s actual status. 
  100                                      //应当与实际一至晶振频率,10MHz~25MHz,应当与实际一至
  101          #define Fcclk           (Fosc * 4)                  //System frequence,should be (1~32)multiples of Fosc,
             -and should be equal or less  than 60MHz. 
  102                                      //系统频率,必须为Fosc的整数倍(1~32),且<=60MHZ
  103          #define Fcco            (Fcclk * 4)                 //CCO frequence,should be 2、4、8、16 multiples of Fc
             -clk, ranged from 156MHz to 320MHz. 
  104                                      //CCO频率,必须为Fcclk的2、4、8、16倍,范围为156MHz~320MHz
  105          #define Fpclk           (Fcclk / 4) * 1             //VPB clock frequence , must be 1、2、4 multiples of 
             -(Fcclk / 4).
  106                                      //VPB时钟频率,只能为(Fcclk / 4)的1、2、4倍
  107          
  108          
  109          
  110          
  111          //函数声明
  112          void Timer0Init(void);
  113          void PortInit(void);
  114          void VicIntSetup(void);
  115          
  116          //函数声明
  117          void LedDisplay(unsigned char);
  118          void MSPI_SendData(unsigned char);
  119          void DelayNS (uint32 dly);
  120          
  121          
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 3   

  122          /*
  123          *********************************************************************************************************
  124          ** 函数名称 :IRQ_Timer0()
  125          ** 函数功能 :定时器0中断服务程序,取反LED9控制口。
  126          ** 入口参数 :无
  127          ** 出口参数 :无
  128          *********************************************************************************************************
  129          */
  130          
  131          void IRQ_Timer0 (void) __irq
  132          {
  133   1      static unsigned char val = 0;
  134   1      static unsigned int Count = 0;
  135   1        if (Count < 2) {
  136   2          Count ++;
  137   2        }
  138   1        else {
  139   2          Count = 0;
  140   2          IO1PIN ^= (1 << LED1)
  141   2                | (1 << LED2)
  142   2                | (1 << LED3)
  143   2                | (1 << LED4)
  144   2                | (1 << LED5)
  145   2                | (1 << LED6)
  146   2                | (1 << LED7)
  147   2                | (1 << LED8);//LED交替闪烁
  148   2          LedDisplay(LedTab[val]);
  149   2          val ++;
  150   2          val &= 0x0f;
  151   2        }
  152   1        IO0PIN ^= (1 << BEEP);//BEEP蜂鸣
  153   1        T0IR = 0x01;              /* 清除中断标志                                 */
  154   1        VICVectAddr = 0x00;       /* 通知VIC中断处理结束                          */
  155   1      }
  156          
  157          
  158          void VicIntSetup(void)
  159          {
  160   1          /* 设置定时器0中断IRQ */
  161   1          VICIntSelect = 0x00;                /* 所有中断通道设置为IRQ中断            */
  162   1          VICVectCntl0 = 0x20 | 0x04;         /* 设置定时器0中断通道分配最高优先级    */
  163   1          VICVectAddr0 = (uint32)IRQ_Timer0;  /* 设置中断服务程序地址                 */
  164   1          VICIntEnable = 1 << 0x04;           /* 使能定时器0中断                      */
  165   1      }
  166          
  167          void PortInit(void)
  168          {
  169   1          PINSEL0 = 0x00000000;       // 设置管脚连接GPIO
  170   1          PINSEL1 = 0x00000000;       // 设置管脚连接GPIO
  171   1          IO0DIR  = 0x00000000;       // 设置P0口为输入
  172   1          IO1DIR  = 0x00000000;       // 设置P1口为输入
  173   1          
  174   1      //  PINSEL0 |= (P0_29_GPIO << P0_29_PINSEL) | (P0_4_SCK0 << P0_4_PINSEL) | (P0_6_MOSI0 << P0_6_PINSEL);
  175   1      //  PINSEL0 |= (P0_7_GPIO << P0_7_PINSEL);
  176   1      /*
  177   1          PINSEL1 |= (P1_18_GPIO << P1_18_PINSEL)
  178   1                   | (P1_19_GPIO << P1_19_PINSEL)
  179   1                   | (P1_20_GPIO << P1_20_PINSEL)
  180   1                   | (P1_21_GPIO << P1_21_PINSEL)
  181   1                   | (P1_22_GPIO << P1_22_PINSEL)
  182   1                   | (P1_23_GPIO << P1_23_PINSEL)
  183   1                   | (P1_24_GPIO << P1_24_PINSEL)
  184   1                   | (P1_25_GPIO << P1_25_PINSEL);
  185   1      */
  186   1      
  187   1      
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 4   

  188   1          IO0DIR |= (1 << BEEP);      // 设置BEEP控制口为输出 
  189   1      
  190   1          IO0DIR |= (1 << RCLK);      // 设置RCLK控制口为输出 
  191   1          IO0DIR |= (1 << SCK0);      // 设置SCK0控制口为输出 
  192   1          IO0DIR |= (1 << MOSI0);     // 设置MOSI0控制口为输出    
  193   1      
  194   1          IO1DIR |= (1 << LED1)       // 设置LED1为输出   
  195   1                  | (1 << LED2)       // 设置LED2为输出  
  196   1                  | (1 << LED3)       // 设置LED3为输出  
  197   1                  | (1 << LED4)       // 设置LED4为输出  
  198   1                  | (1 << LED5)       // 设置LED5为输出  
  199   1                  | (1 << LED6)       // 设置LED6为输出  
  200   1                  | (1 << LED7)       // 设置LED7为输出  
  201   1                  | (1 << LED8);      // 设置LED8为输出  
  202   1      
  203   1          IO0PIN  = (0 << RCLK)
  204   1                  | (1 << SCK0)
  205   1                  | (1 << MOSI0)
  206   1                  | (1 << BEEP);
  207   1      
  208   1          IO1PIN  = (1 << LED1)
  209   1                  | (1 << LED3)
  210   1                  | (1 << LED5)
  211   1                  | (1 << LED7);
  212   1      }
  213          
  214          void Timer0Init(void)
  215          {
  216   1          /* 定时器0初始化 */
  217   1          T0TC   = 0;         /* 定时器设置为0                                        */
  218   1          T0PR   = 0;         /* 时钟不分频                                           */
  219   1          T0MCR  = 0x03;      /* 设置T0MR0匹配后复位T0TC,并产生中断标志              */
  220   1          T0MR0  = Fpclk / 2; /* 0.5秒钟定时                                          */
  221   1          T0TCR  = 0x01;      /* 启动定时器                                           */
  222   1      }
  223          
  224          void LedDisplay(unsigned char data)
  225          {
  226   1        MSPI_SendData(data);
  227   1        IO0SET = (1 << RCLK);
  228   1        IO0CLR = (1 << RCLK);
  229   1      }
  230          
  231          void MSPI_SendData(unsigned char data)
  232          {
  233   1      unsigned char i;
  234   1        for (i = 0; i < 8; i ++) {
  235   2          IO0CLR = (1 << SCK0);
  236   2          if (data & 0x80) {
  237   3            IO0SET = (1 << MOSI0);
  238   3          }
  239   2          else {
  240   3            IO0CLR = (1 << MOSI0);
  241   3          }
  242   2          data <<= 1;
  243   2          IO0SET = (1 << SCK0);
  244   2        } 
  245   1      }
  246          
  247          /*
  248          *********************************************************************************************************
  249          ** 函数名称 :DelayNS()
  250          ** 函数功能 :长软件延时
  251          ** 入口参数 :dly   延时参数,值越大,延时越久
  252          ** 出口参数 :无
  253          *********************************************************************************************************
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 5   

  254          */
  255          void DelayNS (uint32 dly)
  256          {
  257   1          uint32 i;
  258   1          
  259   1          for ( ; dly>0; dly--)
  260   1              for (i=0; i<50000; i++);
  261   1      }
  262          
  263          /*
  264          *********************************************************************************************************
  265          ** 函数名称 :main()
  266          ** 函数功能 :用P0.7控制BEEP,让BEEP鸣叫。
  267          ** 调试说明 :需将跳线JP5和LED短接。
  268          *********************************************************************************************************
  269          */
  270          int main (void)
  271          {
  272   1          PortInit();
  273   1          Timer0Init();
  274   1          VicIntSetup();
  275   1          while (1)
  276   1          {
  277   2          }           
  278   1          return 0;
  279   1      }
ARM COMPILER V2.42,  TIMERDEMO                                                             12/01/06  09:38:31  PAGE 6   

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN NUMBER (__startup)



*** PUBLICS:
 PUBLIC         Timer0Init?T
 PUBLIC         PortInit?T
 PUBLIC         VicIntSetup?T
 PUBLIC         LedDisplay?T
 PUBLIC         LedDisplay?A
 PUBLIC         MSPI_SendData?T
 PUBLIC         DelayNS?T
 PUBLIC         IRQ_Timer0?A
 PUBLIC         main



*** DATA SEGMENT '?CON?TIMERDEMO':
 00000000          LedTab:
 00000000           BEGIN_INIT
 00000000  C0        DB          0xC0
 00000001  F9        DB          0xF9
 00000002  A4        DB          0xA4
 00000003  B0        DB          0xB0
 00000004  99        DB          0x99
 00000005  92        DB          0x92
 00000006  82        DB          0x82
 00000007  F8        DB          0xF8
 00000008  80        DB          0x80
 00000009  90        DB          0x90
 0000000A  88        DB          0x88
 0000000B  83        DB          0x83

⌨️ 快捷键说明

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