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

📄 timer.lst

📁 ARM入门的好帮手.包含了从简单到相对较复杂的程序.
💻 LST
字号:
##############################################################################
#                                                                            #
# IAR ARM ANSI C/EC++ Compiler V3.10A/W32              05/Nov/2001  14:58:30 #
# Copyright 1999-2001 IAR Systems. All rights reserved.                      #
#                                                                            #
#    Cpu mode     =  arm                                                     #
#    Code model   =  small                                                   #
#    Endian       =  little                                                  #
#    Source file  =  C:\At91\software\projects\bench\Source\timer.c          #
#    Command line =  -I C:\Compil\EW23\ARM\INC\ -I ../../..\ -lcN            #
#                    C:\At91\software\projects\bench\IAR\ARM_INT\List\ -la   #
#                    C:\At91\software\projects\bench\IAR\ARM_INT\List\ -o    #
#                    C:\At91\software\projects\bench\IAR\ARM_INT\Obj\ -e     #
#                    -s9 --debug --cpu_mode arm --code_model small --endian  #
#                    little --cpu=arm7tdmi C:\At91\software\projects\bench\S #
#                    ource\timer.c                                           #
#    List file    =  C:\At91\software\projects\bench\IAR\ARM_INT\List\timer. #
#                    lst                                                     #
#    Object file  =  C:\At91\software\projects\bench\IAR\ARM_INT\Obj\timer.r #
#                    79                                                      #
#                                                                            #
#                                                                            #
##############################################################################

C:\At91\software\projects\bench\Source\timer.c
      1          //*----------------------------------------------------------------------------
      2          //*      ATMEL Microcontroller Software Support  -  ROUSSET  -
      3          //*----------------------------------------------------------------------------
      4          //* The software is delivered "AS IS" without warranty or condition of any
      5          //* kind, either express, implied or statutory. This includes without
      6          //* limitation any warranty or condition with respect to merchantability or
      7          //* fitness for any particular purpose, or against the infringements of
      8          //* intellectual property rights of others.
      9          //*----------------------------------------------------------------------------
     10          //* File Name           : timer.c
     11          //* Object              : bench
     12          //*
     13          //* 1.0 15/05/01 JPP    : Creation
     14          //*----------------------------------------------------------------------------
     15          
     16          
     17          #include "periph/timer_counter/lib_tc.h"
     18          
     19          #define     CHRONO_TC_INIT      ( TC_CLKS_MCK2              |\
     20                                            TC_WAVE | TC_CPCSTOP      |\
     21                                            TC_ASWTRG_CLEAR_OUTPUT )
     22          
     23          #define     CHRONO_TC0_MODE    ( TC_CLKS_MCK2               |\
     24                                           TC_WAVE                    |\
     25                                           TC_CPCTRG                  |\
     26                                           TC_ACPA_CLEAR_OUTPUT       |\
     27                                           TC_ACPC_SET_OUTPUT         |\
     28                                           TC_ASWTRG_SET_OUTPUT )
     29          
     30          #define     CHRONO_TC1_MODE    ( TC_CLKS_XC1                |\
     31                                           TC_WAVE                    |\
     32                                           TC_CPCTRG                  |\
     33                                           TC_ACPA_CLEAR_OUTPUT       |\
     34                                           TC_ACPC_SET_OUTPUT         |\
     35                                           TC_ASWTRG_SET_OUTPUT )
     36          
     37          #define     CHRONO_TC2_MODE    ( TC_CLKS_XC2                |\
     38                                           TC_WAVE                    |\
     39                                           TC_CPCTRG                  |\
     40                                           TC_ACPA_CLEAR_OUTPUT       |\
     41                                           TC_ACPC_SET_OUTPUT         |\
     42                                           TC_ASWTRG_SET_OUTPUT )
     43          
     44          //*----------------------------------------------------------------------------
     45          //* Function Name       : at91_time_rtc_mcki
     46          //* Object              : Calculate the MCKI
     47          //* Input Parameters    : <TC_pt>  timer descriptor
     48          //* Output Parameters   :
     49          //*----------------------------------------------------------------------------
     50          void at91_tc_open_count( const TCBlockDesc *TC_pt )
     51          //* Begin
     52          {
     53          
     54              u_int tmp;
     55              StructTCBlock   *tc_ptr = (StructTCBlock *)TC_pt->tc0_desc->tc_base ;
     56          
     57              //* Open timer for counting
     58              //* Open the Timer Counter channels
     59              at91_tc_open (TC_pt->tc0_desc, CHRONO_TC_INIT, TRUE, FALSE);
     60              at91_tc_open (TC_pt->tc1_desc, CHRONO_TC_INIT, TRUE, FALSE);
     61              at91_tc_open (TC_pt->tc2_desc, CHRONO_TC_INIT, TRUE, FALSE);
     62          
     63              //* Setup TIOA outputs to 0
     64              tc_ptr->TC[0].TC_RC = 2 ;
     65              tc_ptr->TC[0].TC_CCR = TC_CLKEN ;
     66              tc_ptr->TC[1].TC_RC = 2 ;
     67              tc_ptr->TC[1].TC_CCR = TC_CLKEN ;
     68              tc_ptr->TC[2].TC_RC = 2 ;
     69              tc_ptr->TC[2].TC_CCR = TC_CLKEN ;
     70              tc_ptr->TC_BCR = TC_SYNC ;
     71          
     72              //* Define the Timer Counter channel Chaining
     73              tc_ptr->TC_BMR = TC_TIOA0XC1 | TC_TIOA1XC2 ;
     74          
     75              //* Setup Timer 0
     76              tc_ptr->TC[0].TC_CMR = CHRONO_TC0_MODE ;
     77              tc_ptr->TC[0].TC_RC = 1000 ;
     78              tc_ptr->TC[0].TC_RA = 500 ;
     79              tc_ptr->TC[0].TC_CCR = TC_CLKEN ;
     80          
     81              //* Setup Timer 1
     82              tc_ptr->TC[1].TC_CMR = CHRONO_TC1_MODE ;
     83              tc_ptr->TC[1].TC_RC = 1000 ;
     84              tc_ptr->TC[1].TC_RA = 500 ;
     85              tc_ptr->TC[1].TC_CCR = TC_CLKEN ;
     86          
     87              //* Setup Timer 2
     88              tc_ptr->TC[2].TC_CMR = CHRONO_TC2_MODE ;
     89              tc_ptr->TC[2].TC_RC = 0xFFFF ;
     90              tc_ptr->TC[2].TC_CCR = TC_CLKEN ;
     91          
     92              //* Clear the status
     93              tmp = tc_ptr->TC[0].TC_SR ;
     94              tmp = tc_ptr->TC[1].TC_SR ;
     95              tmp = tc_ptr->TC[2].TC_SR ;
     96          
     97              //* Trig Timer2
     98              tc_ptr->TC[2].TC_CCR = TC_SWTRG ;
     99          
    100              //* Trig Timer1, set TIOA and effective clear timer 2
    101              tc_ptr->TC[1].TC_CCR = TC_SWTRG ;
    102          
    103          }
    104          //*----------------------------------------------------------------------------
    105          //* Function Name       : at91_tc_start
    106          //* Object              :
    107          //* Input Parameters    : <TC_pt>  timer descriptor
    108          //* Output Parameters   :
    109          //*----------------------------------------------------------------------------
    110          void at91_tc_start( const TCBlockDesc *TC_pt )
    111          {
    112              //* -- Start timer by Software Trigger
    113              //* Trig Timer0, set TIOA and effective clear timer 1
    114              TC_pt->tc0_desc->tc_base->TC_CCR = TC_SWTRG ;
    115          }
    116          //*----------------------------------------------------------------------------
    117          //* Function Name       : at91_tc_stop
    118          //* Object              :
    119          //* Input Parameters    : <TC_pt>  timer descriptor
    120          //* Output Parameters   :
    121          //*----------------------------------------------------------------------------
    122          u_int at91_tc_stop( const TCBlockDesc *TC_pt )
    123          {
    124          	u_int mcki;
    125              StructTCBlock   *tc_ptr = (StructTCBlock *)TC_pt->tc0_desc->tc_base ;
    126          
    127              //* Disable the clock of the Timer Counter channel 0
    128              TC_pt->tc0_desc->tc_base->TC_CCR = TC_CLKDIS ;
    129          
    130              //* Compute number of microseconds from counter values
    131              mcki =  tc_ptr->TC[0].TC_CV  ;
    132              mcki += ( tc_ptr->TC[1].TC_CV * 1000 ) ;
    133              mcki += ( tc_ptr->TC[2].TC_CV * 1000000 ) ;
    134              // TIMER CLOCK MCKI / 2
    135              mcki = mcki*2;
    136          
    137              //* Disable the clock and reset the timer
    138              // Close the timer
    139              at91_tc_close (TC_pt->tc0_desc);
    140              at91_tc_close (TC_pt->tc1_desc);
    141              at91_tc_close (TC_pt->tc2_desc);
    142          
    143              return mcki;
    144          //* End
    145          }

   Maximum stack usage in bytes:

     Function            CSTACK
     --------            ------
     at91_tc_open_count     16 
     at91_tc_start           0 
     at91_tc_stop           12 

 
 380 bytes in segment NEARFUNC_A
 
 380 bytes of CODE memory

Errors: none
Warnings: 1

⌨️ 快捷键说明

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