##############################################################################
#                                                                            #
# IAR ARM ANSI C/C++ Compiler V4.11A/W32               20/Jul/2004  18:58:46 #
# Copyright 1999-2004 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode        =  arm                                                  #
#    Endian          =  little                                               #
#    Stack alignment =  4                                                    #
#    Source file     =  C:\medusa\pll.c                                      #
#    Command line    =  -I "C:\Program Files\IAR Systems\Embedded Workbench  #
#                       4.0\ARM\INC\" -lc C:\medusa\Debug\List\ -la          #
#                       C:\medusa\Debug\List\ -o C:\medusa\Debug\Obj\ -s2    #
#                       --no_cse --no_unroll --no_inline --no_code_motion    #
#                       --no_tbaa --no_clustering --no_scheduling --debug    #
#                       --cpu_mode arm --endian little --cpu ARM7TDMI-S      #
#                       --stack_align 4 -e --fpu None                        #
#                       "-D_DLIB_CONFIG_FILE=C:\Program Files\IAR            #
#                       Systems\Embedded Workbench                           #
#                       4.0\ARM\LIB\dl4tpannl8n.h" C:\medusa\pll.c           #
#    List file       =  C:\medusa\Debug\List\pll.lst                         #
#    Object file     =  C:\medusa\Debug\Obj\pll.r79                          #
#                                                                            #
#                                                                            #
##############################################################################

C:\medusa\pll.c
      1          #include "archinc.h"
      2          #include "pll.h"
      3          
      4          #ifndef CONFIG_INPUT_CLOCK_HZ
      5          #error "No input clock frequency defined!"
      6          #endif
      7          
      8          static unsigned int cpuFreqHz = CONFIG_INPUT_CLOCK_HZ;
      9          static unsigned int vpbDivider = 4;
     10          static unsigned int pllMultiplier = 1;
     11          
     12          static unsigned int pllStatus;
                                     ^
Warning[Pe550]: variable "pllStatus" was set but never used
     13          
     14          #ifdef CONFIG_TOOLCHAIN_IAR
     15          #pragma inline
     16          #endif
     17          static INLINE_KEYWORD void pllPassword(void)
     18          {
     19            IRQ_DISABLE();
     20            PLLFEED = (lpc210x_reg)0xAA;
     21            PLLFEED = (lpc210x_reg)0x55;
     22            IRQ_ENABLE();
     23          }
     24          
     25          #ifdef CONFIG_TOOLCHAIN_IAR
     26          #pragma inline
     27          #endif
     28          static INLINE_KEYWORD void pllWaitLock(void)
     29          {
     30            while (!(PLLSTAT & 0x0400));
     31          }
     32          
     33          int pllInit(void) 
     34          {
     35          #ifdef CONFIG_INCLUDE_LPC210X_PLL
     36          
     37          #ifdef CONFIG_BOARD_MEDUSA
     38            PLLCFG = (lpc210x_reg)0x02; // multiply by 3, divide by 1
     39            pllMultiplier = 3;
     40          #endif
     41          
     42          #ifdef CONFIG_BOARD_OLIMEX
     43            PLLCFG = (lpc210x_reg)0x03; // multiply by 4, divide by 1
     44            pllMultiplier = 4;
     45          #endif
     46          
     47            // enable the PLL and wait for lock
     48            PLLCON = (lpc210x_reg)0x01;
     49            pllPassword();
     50            pllWaitLock();
     51          
     52            // wonder twin powers, activate!
     53            PLLCON = (lpc210x_reg)0x03;
     54            pllPassword();
     55          
     56          #endif
     57          
     58            // update cpu frequency so pllGetPeriphFreq() is correct
     59            cpuFreqHz *= pllMultiplier;
     60          
     61            pllStatus = PLLSTAT;
     62          
     63            return 0;
     64          }
     65          
     66          int pllSetPeriphDivider(unsigned int divider)
     67          {
     68            int retVal = -1;
     69          
     70            switch (divider) {
     71              case 1:
     72                VPBDIV = (lpc210x_reg)0x01;
     73                vpbDivider = 1;
     74                retVal = -1;
     75                break;
     76              case 2:
     77                VPBDIV = (lpc210x_reg)0x02;
     78                vpbDivider = 2;
     79                retVal = -1;
     80                break;
     81              case 4:
     82                VPBDIV = (lpc210x_reg)0x00;
     83                vpbDivider = 4;
     84                retVal = -1;
     85                break;
     86              default:
     87                break;
     88              }
     89          
     90            return retVal;
     91          }
     92          // returns current clock frequency in khz
     93          unsigned int pllGetCpuFreq(void)
     94          {
     95            // TODO: get these values from registers
     96            return cpuFreqHz;
     97          }
     98          
     99          unsigned int pllGetPeriphFreq(void)
    100          {
    101            // TODO: get these values from registers
    102            return (cpuFreqHz/vpbDivider);
    103          }
    104          
    105          unsigned int pllGetPeriphDivider(void)
    106          {
    107            return vpbDivider;
    108          }
    109          
    110          

   Maximum stack usage in bytes:

     Function            CSTACK
     --------            ------
     pllGetCpuFreq           0
     pllGetPeriphDivider     0
     pllGetPeriphFreq        4
     pllInit                 4
     pllPassword             4
     pllSetPeriphDivider     0
     pllWaitLock             0


   Segment part sizes:

     Function/Label                 Bytes
     --------------                 -----
     cpuFreqHz                         4
     vpbDivider                        4
     pllMultiplier                     4
     pllStatus                         4
     pllPassword                      44
     ??pllWaitLock_0                  20
     pllInit                         132
     pllSetPeriphDivider             156
     pllGetCpuFreq                    12
     pllGetPeriphFreq                 32
     pllGetPeriphDivider              12
     ??DataTable3                      4
     ??DataTable8                      4
     ??DataTable10                     4
     ?<Initializer for cpuFreqHz>      4
     ?<Initializer for vpbDivider>     4
     ?<Initializer for pllMultiplier>
                                       4
      Others                          60

 
 456 bytes in segment CODE
  12 bytes in segment DATA_I
  12 bytes in segment DATA_ID
   4 bytes in segment DATA_Z
  24 bytes in segment INITTAB
 
 420 bytes of CODE  memory (+ 60 bytes shared)
  12 bytes of CONST memory
  16 bytes of DATA  memory

Errors: none
Warnings: 1
