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

📄 blinky.lst

📁 PWM Example for Philips LPC2
💻 LST
字号:
ARM COMPILER V0.07,  Blinky                                                                14/07/04  10:49:40  PAGE 1   


ARM COMPILER V0.07, COMPILATION OF MODULE Blinky
OBJECT MODULE PLACED IN .\Flash\Blinky.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe Blinky.c BROWSE DEBUG PRINT(.\FLASH\BLINKY.LST) TABS(4) OBJECT(.\Flash\Blink
                    -y.obj) 

stmt  level    source

    1          /******************************************************************************/
    2          /*  This file is part of the uVision/ARM development tools                    */
    3          /*  Copyright KEIL ELEKTRONIK GmbH 2002-2004                                  */
    4          /******************************************************************************/
    5          /*                                                                            */
    6          /*  BLINKY.C:  LED Flasher                                                    */
    7          /*                                                                            */
    8          /******************************************************************************/
    9                            
   10          #include <stdio.h>                         /* standard I/O .h-file */
   11          #include <LPC21xx.H>                       /* LPC21xx definitions  */
   12          
   13          extern void init_uart0 (void);
   14          extern void sendstr (char *);
   15          
   16          //
   17          // PWM Interrupt Service Routine
   18          //
   19          
   20          void PWM0_isr(void)  __irq 
   21          {
   22   1                                              // do processing here
   23   1          PWMIR       |= 0x00000001;              //Clear match0 interrupt
   24   1          VICVectAddr  = 0x00000000;              //Dummy write to signal end of interrupt
   25   1      
   26   1      }
   27          
   28          void init_clock(void)
   29          {
   30   1        PLLCFG = 0x04;                // Set multiplier and divider of PLL to give 55.296 Mhz
   31   1        PLLCON = 0x01;                // Enable the PLL
   32   1        
   33   1        PLLFEED = 0xAA;               // Update PLL registers
   34   1        PLLFEED = 0x55;
   35   1        
   36   1        while (!(PLLSTAT & 0x400))    // test Lock bit
   37   1        {
   38   2          PLLFEED = 0xAA;             // not sure if this is necessary
   39   2          PLLFEED = 0x55;
   40   2        }
   41   1        PLLCON = 0x03;                // Connect the PLL
   42   1        
   43   1        PLLFEED = 0xAA;               //Update PLL registers
   44   1        PLLFEED = 0x55;
   45   1        
   46   1        VPBDIV = 0x02;                //Set the VLSI peripheral bus to 27.648
   47   1      }
   48          
   49          int init_PWM (void) {
   50   1      
   51   1          VICVectAddr8 = (unsigned)PWM0_isr;      //Set the PWM ISR vector address
   52   1          VICVectCntl8 = 0x00000028;              //Set channel
   53   1          VICIntEnable = 0x00000100;              //Enable the interrupt
   54   1      
   55   1          PINSEL0 |= 0x00028000;                  //Enable pin 0.7   as PWM2 
   56   1          PWMPR    = 0x00000001;                  //Load prescaler
   57   1      
   58   1          PWMPCR = 0x0000404;                     //PWM channel 2 double edge control, output enabled
ARM COMPILER V0.07,  Blinky                                                                14/07/04  10:49:40  PAGE 2   

   59   1          PWMMCR = 0x00000003;                    //On match with timer reset the counter
   60   1          PWMMR0 = 0x00000010;                    //set cycle rate to sixteen ticks
   61   1          PWMMR1 = 0x00000002;                    //set rising edge of PWM2 to 2 ticks
   62   1          PWMMR2 = 0x00000008;                    //set falling edge of PWM2 to 8 ticks
   63   1          PWMLER = 0x00000007;                    //enable shadow latch for match 0 - 2 
   64   1          PWMEMR = 0x00000280;                    //Match 1 and Match 2 outputs set high
   65   1          PWMTCR = 0x00000002;                    //Reset counter and prescaler 
   66   1          PWMTCR = 0x00000009;                    //enable counter and PWM, release counter from reset
   67   1      
   68   1      
   69   1      
   70   1      
   71   1      return 0;
   72   1      }
   73          
   74          int main (void) {
   75   1        unsigned int n;
   76   1        int rx_char;
   77   1      
   78   1        init_clock();
   79   1        init_uart0();
   80   1        init_PWM();
   81   1      
   82   1        printf("Test1");
   83   1      
   84   1        while (1) {                              /* Loop forever */
   85   2      
   86   2          rx_char = getchar();
   87   2           switch(rx_char) {
   88   3            case 0x2B:                                //If + key is pressed
   89   3              PWMMR1--;                               //Decrement rising edge of double PWM
   90   3              PWMMR2++;                               //Increment falling edge of double pwm
   91   3              PWMLER =  0x00000006;                   //Enable Shadow latch
   92   3              rx_char = 0x00000000;                   //Clear rx_char
   93   3            break;
   94   3            case 0x2D:                                // If - key is pressed
   95   3              PWMMR1++;                               //Increment rising edge of double PWM
   96   3              PWMMR2--;                               //Decrement falling edge of double pwm
   97   3              PWMLER = 0x0000006;                     //Enable Shadow latch
   98   3              rx_char = 0x00000000;                   //Clear rx_char
   99   3            break;
  100   3           }
  101   2        }
  102   1      }

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

⌨️ 快捷键说明

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