; generated by Component: ARM Compiler 5.06 update 7 (build 960) Tool: ArmCC [4d365d]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o..\output\tim_inputcapture.o --asm_dir=..\List\ --list_dir=..\List\ --depend=..\output\tim_inputcapture.d --cpu=Cortex-M0+ --apcs=interwork --diag_suppress=9931 -I..\FWLib\SC32F1XXX_Lib\inc -I..\User\HeadFiles -I..\User -I..\Drivers -I..\Apps -I..\CMSIS -IF:\Users\SOC\AppData\Local\Arm\Packs\ARM\CMSIS\5.8.0\Device\ARM\ARMCM0plus\Include -D__UVISION_VERSION=536 -DARMCM0P -DSC32f10xx --omf_browse=..\output\tim_inputcapture.crf ..\Apps\TIM_InputCapture.c]
                          THUMB

                          AREA ||i.TIM_InputCapture_Function||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_percent
                          REQUIRE _printf_d
                          REQUIRE _printf_int_dec
                  TIM_InputCapture_Function PROC
;;;23     
;;;24     void TIM_InputCapture_Function(void)
000000  b086              SUB      sp,sp,#0x18
;;;25     {
;;;26       volatile uint16_t TIM_IC_Cycle, TIM_IC_Duty;
;;;27       TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
;;;28       TIM_IC_InitTypeDef TIM_IC_InitStruct;
;;;29     
;;;30       /* 使能TIM1时钟 */
;;;31       RCC_APB0Cmd(ENABLE);
000002  2001              MOVS     r0,#1
000004  f7fffffe          BL       RCC_APB0Cmd
;;;32       RCC_APB0PeriphClockCmd(RCC_APB0Periph_TIM1, ENABLE);
000008  2101              MOVS     r1,#1
00000a  2002              MOVS     r0,#2
00000c  f7fffffe          BL       RCC_APB0PeriphClockCmd
;;;33     
;;;34       /* TIM配置结构体初始化 */
;;;35       TIM_TimeBaseStructInit(&TIM_TimeBaseInitStruct);
000010  4668              MOV      r0,sp
000012  f7fffffe          BL       TIM_TimeBaseStructInit
;;;36       TIM_ICStructInit(&TIM_IC_InitStruct);
000016  a803              ADD      r0,sp,#0xc
000018  f7fffffe          BL       TIM_ICStructInit
;;;37     
;;;38       /* 设置TIM时基配置结构体 */
;;;39       TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up;	//TIM工作在向上计数模式
00001c  2500              MOVS     r5,#0
00001e  4669              MOV      r1,sp
000020  808d              STRH     r5,[r1,#4]
;;;40       TIM_TimeBaseInitStruct.TIM_EXENX = TIM_EXENX_Disable;	//外部重加载管脚失能
000022  80cd              STRH     r5,[r1,#6]
;;;41     #if defined(SC32f10xx)||defined(SC32f12xx)
;;;42       TIM_TimeBaseInitStruct.TIM_Preload = 65535 - (32000000 / 1000);	//设置TIM的定时器评论为1000Hz@APB0Clock=32M
000024  481c              LDR      r0,|L1.152|
000026  8108              STRH     r0,[r1,#8]
;;;43     #endif
;;;44       TIM_TimeBaseInitStruct.TIM_Prescaler = TIM_PRESCALER_1;	//TIM分频为1分频
;;;45       TIM_TimeBaseInitStruct.TIM_WorkMode = TIM_WorkMode_Timer;	//TIM工作在定时器模式，时钟源为APB0时钟
;;;46     
;;;47       /* TIM时基配置 */
;;;48       TIM_TIMBaseInit(TIM1, &TIM_TimeBaseInitStruct);
000028  4c1c              LDR      r4,|L1.156|
00002a  800d              STRH     r5,[r1,#0]            ;44
00002c  804d              STRH     r5,[r1,#2]            ;45
00002e  4620              MOV      r0,r4
000030  f7fffffe          BL       TIM_TIMBaseInit
;;;49     
;;;50       /* 设置TIM捕获通道配置结构体 */
;;;51       TIM_IC_InitStruct.TIM_FICPIN = TIM_FICPin_Tn;
000034  2208              MOVS     r2,#8
000036  4669              MOV      r1,sp
000038  81ca              STRH     r2,[r1,#0xe]
;;;52       TIM_IC_InitStruct.TIM_RICPIN = TIM_RICPin_Tn;
00003a  2004              MOVS     r0,#4
00003c  8188              STRH     r0,[r1,#0xc]
;;;53     
;;;54       /* TIM捕获配置 */
;;;55       TIM_ICInit(TIM1, &TIM_IC_InitStruct);
00003e  a903              ADD      r1,sp,#0xc
000040  4620              MOV      r0,r4
000042  f7fffffe          BL       TIM_ICInit
;;;56       TIM_ICCmd(TIM1,ENABLE);
000046  2101              MOVS     r1,#1
000048  4620              MOV      r0,r4
00004a  f7fffffe          BL       TIM_ICCmd
;;;57       /* 使能TIM1中断 */
;;;58       TIM_ITConfig(TIM1, TIM_IT_TI | TIM_IT_INTEN | TIM_IT_EXF | TIM_IT_EXR, ENABLE);
00004e  2201              MOVS     r2,#1
000050  210f              MOVS     r1,#0xf
000052  4620              MOV      r0,r4
000054  f7fffffe          BL       TIM_ITConfig
000058  2001              MOVS     r0,#1
00005a  4911              LDR      r1,|L1.160|
00005c  0400              LSLS     r0,r0,#16
00005e  6008              STR      r0,[r1,#0]
;;;59       NVIC_EnableIRQ(TIMER1_IRQn);
;;;60     
;;;61       /* TIM外设初始化 */
;;;62       TIM_Cmd(TIM1, ENABLE);
000060  2101              MOVS     r1,#1
000062  4620              MOV      r0,r4
000064  f7fffffe          BL       TIM_Cmd
;;;63     
;;;64       while(1)
;;;65       {
;;;66         if(TIM_ICNum == 3)
000068  4c0e              LDR      r4,|L1.164|
;;;67         {
;;;68           /* 周期为两次上升沿的差值，占空比为下降沿减去第一次上升沿的差值 */
;;;69           TIM_IC_Cycle = TIM_ICValue.SecondRising - TIM_ICValue.FirstRising;
00006a  1ca6              ADDS     r6,r4,#2
                  |L1.108|
00006c  7820              LDRB     r0,[r4,#0]            ;66  ; TIM_ICNum
00006e  2803              CMP      r0,#3                 ;66
000070  d1fc              BNE      |L1.108|
000072  88b1              LDRH     r1,[r6,#4]  ; TIM_ICValue
000074  8830              LDRH     r0,[r6,#0]  ; TIM_ICValue
000076  466a              MOV      r2,sp
000078  1a09              SUBS     r1,r1,r0
00007a  8211              STRH     r1,[r2,#0x10]
;;;70           TIM_IC_Duty = TIM_ICValue.FirstFailing - TIM_ICValue.FirstRising;
00007c  8871              LDRH     r1,[r6,#2]  ; TIM_ICValue
00007e  1a08              SUBS     r0,r1,r0
000080  8290              STRH     r0,[r2,#0x14]
;;;71           
;;;72           /* 打印捕获值 */
;;;73           printf("The captured cycle is %d.\r\n", TIM_IC_Cycle);
000082  8a11              LDRH     r1,[r2,#0x10]
000084  a008              ADR      r0,|L1.168|
000086  f7fffffe          BL       __2printf
;;;74           printf("The captured duty is %d.\r\n ", TIM_IC_Duty);
00008a  466a              MOV      r2,sp
00008c  8a91              LDRH     r1,[r2,#0x14]
00008e  a00d              ADR      r0,|L1.196|
000090  f7fffffe          BL       __2printf
;;;75           
;;;76           TIM_ICNum = 0;
000094  7025              STRB     r5,[r4,#0]
000096  e7e9              B        |L1.108|
;;;77         }
;;;78       }
;;;79     }
;;;80     
                          ENDP

                  |L1.152|
                          DCD      0x000082ff
                  |L1.156|
                          DCD      0x40020140
                  |L1.160|
                          DCD      0xe000e100
                  |L1.164|
                          DCD      ||.data||
                  |L1.168|
0000a8  54686520          DCB      "The captured cycle is %d.\r\n",0
0000ac  63617074
0000b0  75726564
0000b4  20637963
0000b8  6c652069
0000bc  73202564
0000c0  2e0d0a00
                  |L1.196|
0000c4  54686520          DCB      "The captured duty is %d.\r\n ",0
0000c8  63617074
0000cc  75726564
0000d0  20647574
0000d4  79206973
0000d8  2025642e
0000dc  0d0a2000

                          AREA ||i.TIM_InputCapture_TIM1Handler||, CODE, READONLY, ALIGN=2

                  TIM_InputCapture_TIM1Handler PROC
;;;80     
;;;81     void TIM_InputCapture_TIM1Handler(void)
000000  b570              PUSH     {r4-r6,lr}
;;;82     {
;;;83       /* 判断TIM1中断是否置起 */
;;;84       if(TIM_GetFlagStatus(TIM1, TIM_Flag_TI) == SET)
000002  4e20              LDR      r6,|L2.132|
000004  2101              MOVS     r1,#1
000006  4630              MOV      r0,r6
000008  f7fffffe          BL       TIM_GetFlagStatus
;;;85       {
;;;86         TIM_ClearFlag(TIM1, TIM_Flag_TI);	//清除TIM1中断
;;;87         TIM_ICNum = 0;	//清除捕获标志值
00000c  4c1e              LDR      r4,|L2.136|
00000e  2801              CMP      r0,#1                 ;84
000010  d105              BNE      |L2.30|
000012  2101              MOVS     r1,#1                 ;86
000014  4630              MOV      r0,r6                 ;86
000016  f7fffffe          BL       TIM_ClearFlag
00001a  2000              MOVS     r0,#0
00001c  7020              STRB     r0,[r4,#0]
                  |L2.30|
;;;88       }
;;;89       if(TIM_GetFlagStatus(TIM1, TIM_Flag_EXR) == SET)
00001e  2102              MOVS     r1,#2
000020  4630              MOV      r0,r6
000022  f7fffffe          BL       TIM_GetFlagStatus
;;;90       {
;;;91         TIM_ClearFlag(TIM1, TIM_Flag_EXR);	//清除TIM1中断
;;;92         if(TIM_ICNum == 0)	//采集到第一次上升沿
;;;93         {
;;;94           TIM_ICNum ++;
;;;95           TIM_ICValue.FirstRising = TIM_GetRisingCapture(TIM1);
000026  4d18              LDR      r5,|L2.136|
000028  1cad              ADDS     r5,r5,#2
00002a  2801              CMP      r0,#1                 ;89
00002c  d115              BNE      |L2.90|
00002e  2102              MOVS     r1,#2                 ;91
000030  4630              MOV      r0,r6                 ;91
000032  f7fffffe          BL       TIM_ClearFlag
000036  7820              LDRB     r0,[r4,#0]            ;92  ; TIM_ICNum
000038  2800              CMP      r0,#0                 ;92
00003a  d105              BNE      |L2.72|
00003c  2001              MOVS     r0,#1                 ;94
00003e  7020              STRB     r0,[r4,#0]            ;94
000040  4630              MOV      r0,r6
000042  f7fffffe          BL       TIM_GetRisingCapture
000046  8028              STRH     r0,[r5,#0]
                  |L2.72|
;;;96         }
;;;97         if(TIM_ICNum == 2)	//采集到第二次上升沿
000048  7820              LDRB     r0,[r4,#0]  ; TIM_ICNum
00004a  2802              CMP      r0,#2
00004c  d105              BNE      |L2.90|
;;;98         {
;;;99           TIM_ICNum ++;
00004e  2003              MOVS     r0,#3
000050  7020              STRB     r0,[r4,#0]
;;;100          TIM_ICValue.SecondRising = TIM_GetRisingCapture(TIM1);
000052  4630              MOV      r0,r6
000054  f7fffffe          BL       TIM_GetRisingCapture
000058  80a8              STRH     r0,[r5,#4]
                  |L2.90|
;;;101        }
;;;102      }
;;;103      if(TIM_GetFlagStatus(TIM1, TIM_Flag_EXF) == SET)
00005a  2104              MOVS     r1,#4
00005c  4630              MOV      r0,r6
00005e  f7fffffe          BL       TIM_GetFlagStatus
000062  2801              CMP      r0,#1
000064  d10c              BNE      |L2.128|
;;;104      {
;;;105        TIM_ClearFlag(TIM1, TIM_Flag_EXF);	//清除TIM1中断
000066  2104              MOVS     r1,#4
000068  4630              MOV      r0,r6
00006a  f7fffffe          BL       TIM_ClearFlag
;;;106        if(TIM_ICNum == 1)	//采集到第一次下降沿
00006e  7820              LDRB     r0,[r4,#0]  ; TIM_ICNum
000070  2801              CMP      r0,#1
000072  d105              BNE      |L2.128|
;;;107        {
;;;108          TIM_ICNum++;
000074  2002              MOVS     r0,#2
000076  7020              STRB     r0,[r4,#0]
;;;109          TIM_ICValue.FirstFailing = TIM_GetFailingCapture(TIM1);
000078  4630              MOV      r0,r6
00007a  f7fffffe          BL       TIM_GetFailingCapture
00007e  8068              STRH     r0,[r5,#2]
                  |L2.128|
;;;110        }
;;;111      }
;;;112    }
000080  bd70              POP      {r4-r6,pc}
                          ENDP

000082  0000              DCW      0x0000
                  |L2.132|
                          DCD      0x40020140
                  |L2.136|
                          DCD      ||.data||

                          AREA ||.data||, DATA, ALIGN=1

                  TIM_ICNum
000000  0000              DCB      0x00,0x00
                  TIM_ICValue
000002  0000              DCB      0x00,0x00
                          DCDU     0x00000000

;*** Start embedded assembler ***

#line 1 "..\\Apps\\TIM_InputCapture.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___18_TIM_InputCapture_c_e06c8efe____REV16|
#line 463 "..\\CMSIS\\cmsis_armcc.h"
|__asm___18_TIM_InputCapture_c_e06c8efe____REV16| PROC
#line 464

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___18_TIM_InputCapture_c_e06c8efe____REVSH|
#line 478
|__asm___18_TIM_InputCapture_c_e06c8efe____REVSH| PROC
#line 479

 revsh r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***
