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

📄 pwmc.lst

📁 Tried to make CAN logger on AT91sam7X-ek, but have no idea how to implement FATFs... -( I m just a
💻 LST
📖 第 1 页 / 共 3 页
字号:
###############################################################################
#                                                                             #
#                                                       25/May/2009  02:53:23 #
# IAR ANSI C/C++ Compiler V5.20.0.20892/W32 EVALUATION for ARM                #
# Copyright 1999-2008 IAR Systems AB.                                         #
#                                                                             #
#    Cpu mode     =  arm                                                      #
#    Endian       =  little                                                   #
#    Source file  =  F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91lib\peripherals\pwmc\pwmc.c             #
#    Command line =  F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91lib\peripherals\pwmc\pwmc.c -D          #
#                    at91sam7x256 -D flash -D TRACE_LEVEL=4 -lC               #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\at #
#                    91sam7x256_flash\List\ --remarks --diag_suppress         #
#                    Pe826,Pe1375 -o F:\Diplomovka\IARprojects\Diplomovka\25. #
#                    4.2009\getting-started-project-at91sam7x-ek-iar\getting- #
#                    started-project-at91sam7x-ek\at91sam7x-ek\getting-starte #
#                    d-project\ewp\at91sam7x256_flash\Obj\ --no_cse           #
#                    --no_unroll --no_inline --no_code_motion --no_tbaa       #
#                    --no_clustering --no_scheduling --debug --endian=little  #
#                    --cpu=ARM7TDMI -e --fpu=None --dlib_config "C:\Program   #
#                    Files (x86)\IAR Systems\Embedded Workbench 5.0           #
#                    Evaluation\ARM\INC\DLib_Config_Full.h" -I                #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\.. #
#                    \..\..\at91lib/peripherals\ -I                           #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\.. #
#                    \..\..\at91lib\ -I F:\Diplomovka\IARprojects\Diplomovka\ #
#                    25.4.2009\getting-started-project-at91sam7x-ek-iar\getti #
#                    ng-started-project-at91sam7x-ek\at91sam7x-ek\getting-sta #
#                    rted-project\ewp\..\..\..\at91lib\memories\sdmmc\ -I     #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\.. #
#                    \..\..\at91lib/components\ -I                            #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\.. #
#                    \..\..\at91lib/boards/at91sam7x-ek\ -I                   #
#                    F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\.. #
#                    \..\..\external_libs/crc\ -I "C:\Program Files           #
#                    (x86)\IAR Systems\Embedded Workbench 5.0                 #
#                    Evaluation\ARM\INC\" --interwork --cpu_mode arm -Oh      #
#    List file    =  F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\at #
#                    91sam7x256_flash\List\pwmc.lst                           #
#    Object file  =  F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-s #
#                    tarted-project-at91sam7x-ek-iar\getting-started-project- #
#                    at91sam7x-ek\at91sam7x-ek\getting-started-project\ewp\at #
#                    91sam7x256_flash\Obj\pwmc.o                              #
#                                                                             #
#                                                                             #
###############################################################################

F:\Diplomovka\IARprojects\Diplomovka\25.4.2009\getting-started-project-at91sam7x-ek-iar\getting-started-project-at91sam7x-ek\at91lib\peripherals\pwmc\pwmc.c
      1          /* ----------------------------------------------------------------------------
      2           *         ATMEL Microcontroller Software Support 
      3           * ----------------------------------------------------------------------------
      4           * Copyright (c) 2008, Atmel Corporation
      5           *
      6           * All rights reserved.
      7           *
      8           * Redistribution and use in source and binary forms, with or without
      9           * modification, are permitted provided that the following conditions are met:
     10           *
     11           * - Redistributions of source code must retain the above copyright notice,
     12           * this list of conditions and the disclaimer below.
     13           *
     14           * Atmel's name may not be used to endorse or promote products derived from
     15           * this software without specific prior written permission.
     16           *
     17           * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
     18           * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19           * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
     20           * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
     21           * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22           * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
     23           * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     24           * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     25           * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     26           * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27           * ----------------------------------------------------------------------------
     28           */
     29          
     30          //------------------------------------------------------------------------------
     31          //         Headers
     32          //------------------------------------------------------------------------------
     33          
     34          #include "pwmc.h"
     35          #include <board.h>
     36          #include <utility/assert.h>
     37          #include <utility/trace.h>
     38          
     39          //------------------------------------------------------------------------------
     40          //         Local functions
     41          //------------------------------------------------------------------------------
     42          
     43          //------------------------------------------------------------------------------
     44          /// Finds a prescaler/divisor couple to generate the desired frequency from
     45          /// MCK.
     46          /// Returns the value to enter in PWMC_MR or 0 if the configuration cannot be
     47          /// met.
     48          /// \param frequency  Desired frequency in Hz.
     49          /// \param mck  Master clock frequency in Hz.
     50          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
     51          static unsigned short FindClockConfiguration(
     52              unsigned int frequency,
     53              unsigned int mck)
     54          {
   \                     FindClockConfiguration:
   \   00000000   70402DE9           PUSH     {R4-R6,LR}
   \   00000004   30D04DE2           SUB      SP,SP,#+48
   \   00000008   0040A0E1           MOV      R4,R0
   \   0000000C   0150A0E1           MOV      R5,R1
     55              unsigned int divisors[11] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024};
   \   00000010   0D00A0E1           MOV      R0,SP
   \   00000014   88109FE5           LDR      R1,??FindClockConfiguration_0  ;; `?<Constant {1, 2, 4, 8, 16, 32, 64, 128, 256, `
   \   00000018   2C20A0E3           MOV      R2,#+44
   \   0000001C   ........           BL       __aeabi_memcpy4
     56              unsigned char divisor = 0;
   \   00000020   0060A0E3           MOV      R6,#+0
     57              unsigned int prescaler;
     58          
     59              SANITY_CHECK(frequency < mck);
   \   00000024   050054E1           CMP      R4,R5
   \   00000028   0600003A           BCC      ??FindClockConfiguration_1
   \   0000002C   ........           LDR      R0,??DataTable23  ;; `?<Constant "-F- ASSERT: ">`
   \   00000030   ........           BL       printf
   \   00000034   3B20A0E3           MOV      R2,#+59
   \   00000038   ........           LDR      R1,??DataTable24  ;; `?<Constant "F:\\\\Diplomovka\\\\IARproj...">`
   \   0000003C   ........           LDR      R0,??DataTable25  ;; `?<Constant "Sanity check failed a...">`
   \   00000040   ........           BL       printf
   \                     ??FindClockConfiguration_2:
   \   00000044   FEFFFFEA           B        ??FindClockConfiguration_2
     60          
     61              // Find prescaler and divisor values
     62              prescaler = (mck / divisors[divisor]) / frequency;
   \                     ??FindClockConfiguration_1:
   \   00000048   0500A0E1           MOV      R0,R5
   \   0000004C   00109DE5           LDR      R1,[SP, #+0]
   \   00000050   040000EA           B        ??FindClockConfiguration_3
     63              while ((prescaler > 255) && (divisor < 11)) {
     64          
     65                  divisor++;
   \                     ??FindClockConfiguration_4:
   \   00000054   016086E2           ADD      R6,R6,#+1
   \   00000058   FF6006E2           AND      R6,R6,#0xFF
     66                  prescaler = (mck / divisors[divisor]) / frequency;
   \   0000005C   0500A0E1           MOV      R0,R5
   \   00000060   0610A0E1           MOV      R1,R6
   \   00000064   01119DE7           LDR      R1,[SP, +R1, LSL #+2]
   \                     ??FindClockConfiguration_3:
   \   00000068   ........           BL       __aeabi_uidivmod
   \   0000006C   0410A0E1           MOV      R1,R4
   \   00000070   ........           BL       __aeabi_uidivmod
     67              }
   \   00000074   400F50E3           CMP      R0,#+256
   \   00000078   0100003A           BCC      ??FindClockConfiguration_5
   \   0000007C   0B0056E3           CMP      R6,#+11
   \   00000080   F3FFFF3A           BCC      ??FindClockConfiguration_4
     68          
     69              // Return result
     70              if (divisor < 11) {
   \                     ??FindClockConfiguration_5:
   \   00000084   0B0056E3           CMP      R6,#+11
     71          
     72                  TRACE_DEBUG("Found divisor=%u and prescaler=%u for freq=%uHz\n\r",
     73                            divisors[divisor], prescaler, frequency);
     74                  return prescaler | (divisor << 8);
   \   00000088   06048031           ORRCC    R0,R0,R6, LSL #+8
   \   0000008C   0008A031           MOVCC    R0,R0, LSL #+16
   \   00000090   2008A031           MOVCC    R0,R0, LSR #+16
     75              }
     76              else {
     77          
     78                  return 0;
   \   00000094   0000A023           MOVCS    R0,#+0
   \   00000098   30D08DE2           ADD      SP,SP,#+48       ;; stack cleaning
   \   0000009C   7040BDE8           POP      {R4-R6,LR}
   \   000000A0   1EFF2FE1           BX       LR               ;; return
   \                     ??FindClockConfiguration_0:
   \   000000A4   ........           DC32     `?<Constant {1, 2, 4, 8, 16, 32, 64, 128, 256, `
     79              }
     80          }
     81          
     82          //------------------------------------------------------------------------------
     83          //         Global functions
     84          //------------------------------------------------------------------------------
     85          
     86          //------------------------------------------------------------------------------
     87          /// Configures PWM a channel with the given parameters.
     88          /// The PWM controller must have been clocked in the PMC prior to calling this
     89          /// function. 
     90          /// Beware: this function disables the channel. It waits until disable is effective.
     91          /// \param channel  Channel number.
     92          /// \param prescaler  Channel prescaler.
     93          /// \param alignment  Channel alignment.
     94          /// \param polarity  Channel polarity.
     95          //------------------------------------------------------------------------------

   \                                 In section .text, align 4, keep-with-next
     96          void PWMC_ConfigureChannel(
     97              unsigned char channel,
     98              unsigned int prescaler,
     99              unsigned int alignment,
    100              unsigned int polarity)
    101          {
   \                     PWMC_ConfigureChannel:
   \   00000000   00502DE9           PUSH     {R12,LR}
    102              SANITY_CHECK(prescaler < AT91C_PWMC_CPRE_MCKB);
   \   00000004   0C0051E3           CMP      R1,#+12
   \   00000008   0600003A           BCC      ??PWMC_ConfigureChannel_0
   \   0000000C   ........           LDR      R0,??DataTable23  ;; `?<Constant "-F- ASSERT: ">`
   \   00000010   ........           BL       printf
   \   00000014   6620A0E3           MOV      R2,#+102
   \   00000018   ........           LDR      R1,??DataTable24  ;; `?<Constant "F:\\\\Diplomovka\\\\IARproj...">`
   \   0000001C   ........           LDR      R0,??DataTable25  ;; `?<Constant "Sanity check failed a...">`
   \   00000020   ........           BL       printf
   \                     ??PWMC_ConfigureChannel_1:
   \   00000024   FEFFFFEA           B        ??PWMC_ConfigureChannel_1
    103              SANITY_CHECK((alignment & ~AT91C_PWMC_CALG) == 0);
   \                     ??PWMC_ConfigureChannel_0:
   \   00000028   40CFD2E3           BICS     R12,R2,#0x100
   \   0000002C   0600000A           BEQ      ??PWMC_ConfigureChannel_2
   \   00000030   ........           LDR      R0,??DataTable23  ;; `?<Constant "-F- ASSERT: ">`
   \   00000034   ........           BL       printf
   \   00000038   6720A0E3           MOV      R2,#+103
   \   0000003C   ........           LDR      R1,??DataTable24  ;; `?<Constant "F:\\\\Diplomovka\\\\IARproj...">`
   \   00000040   ........           LDR      R0,??DataTable25  ;; `?<Constant "Sanity check failed a...">`
   \   00000044   ........           BL       printf
   \                     ??PWMC_ConfigureChannel_3:
   \   00000048   FEFFFFEA           B        ??PWMC_ConfigureChannel_3
    104              SANITY_CHECK((polarity & ~AT91C_PWMC_CPOL) == 0);

⌨️ 快捷键说明

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