STM32F10x_StdPeriph_Examples/TIM/InputCapture/stm32f10x_it.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    TIM/InputCapture/stm32f10x_it.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main Interrupt Service Routines.
00008   *          This file provides template for all exceptions handler and 
00009   *          peripherals interrupt service routine.
00010   ******************************************************************************
00011   * @copy
00012   *
00013   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00014   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00015   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00016   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00017   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00018   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00019   *
00020   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00021   */ 
00022 
00023 /* Includes ------------------------------------------------------------------*/
00024 #include "stm32f10x_it.h"
00025 
00026 /** @addtogroup STM32F10x_StdPeriph_Examples
00027   * @{
00028   */
00029 
00030 /** @addtogroup TIM_Input_Capture
00031   * @{
00032   */ 
00033 
00034 /* Private typedef -----------------------------------------------------------*/
00035 /* Private define ------------------------------------------------------------*/
00036 /* Private macro -------------------------------------------------------------*/
00037 /* Private variables ---------------------------------------------------------*/
00038 __IO uint16_t IC3ReadValue1 = 0, IC3ReadValue2 = 0;
00039 __IO uint16_t CaptureNumber = 0;
00040 __IO uint32_t Capture = 0;
00041 __IO uint32_t TIM3Freq = 0;
00042 
00043 /* Private function prototypes -----------------------------------------------*/
00044 /* Private functions ---------------------------------------------------------*/
00045 
00046 /******************************************************************************/
00047 /*            Cortex-M3 Processor Exceptions Handlers                         */
00048 /******************************************************************************/
00049 
00050 /**
00051   * @brief  This function handles NMI exception.
00052   * @param  None
00053   * @retval None
00054   */
00055 void NMI_Handler(void)
00056 {
00057 }
00058 
00059 /**
00060   * @brief  This function handles Hard Fault exception.
00061   * @param  None
00062   * @retval None
00063   */
00064 void HardFault_Handler(void)
00065 {
00066   /* Go to infinite loop when Hard Fault exception occurs */
00067   while (1)
00068   {}
00069 }
00070 
00071 /**
00072   * @brief  This function handles Memory Manage exception.
00073   * @param  None
00074   * @retval None
00075   */
00076 void MemManage_Handler(void)
00077 {
00078   /* Go to infinite loop when Memory Manage exception occurs */
00079   while (1)
00080   {}
00081 }
00082 
00083 /**
00084   * @brief  This function handles Bus Fault exception.
00085   * @param  None
00086   * @retval None
00087   */
00088 void BusFault_Handler(void)
00089 {
00090   /* Go to infinite loop when Bus Fault exception occurs */
00091   while (1)
00092   {}
00093 }
00094 
00095 /**
00096   * @brief  This function handles Usage Fault exception.
00097   * @param  None
00098   * @retval None
00099   */
00100 void UsageFault_Handler(void)
00101 {
00102   /* Go to infinite loop when Usage Fault exception occurs */
00103   while (1)
00104   {}
00105 }
00106 
00107 /**
00108   * @brief  This function handles Debug Monitor exception.
00109   * @param  None
00110   * @retval None
00111   */
00112 void DebugMon_Handler(void)
00113 {}
00114 
00115 /**
00116   * @brief  This function handles SVCall exception.
00117   * @param  None
00118   * @retval None
00119   */
00120 void SVC_Handler(void)
00121 {}
00122 
00123 /**
00124   * @brief  This function handles PendSV_Handler exception.
00125   * @param  None
00126   * @retval None
00127   */
00128 void PendSV_Handler(void)
00129 {}
00130 
00131 /**
00132   * @brief  This function handles SysTick Handler.
00133   * @param  None
00134   * @retval None
00135   */
00136 void SysTick_Handler(void)
00137 {}
00138 
00139 /******************************************************************************/
00140 /*            STM32F10x Peripherals Interrupt Handlers                        */
00141 /******************************************************************************/
00142 /**
00143   * @brief  This function handles TIM3 global interrupt request.
00144   * @param  None
00145   * @retval None
00146   */
00147 void TIM3_IRQHandler(void)
00148 { 
00149   if(TIM_GetITStatus(TIM3, TIM_IT_CC2) == SET) 
00150   {
00151     /* Clear TIM3 Capture compare interrupt pending bit */
00152     TIM_ClearITPendingBit(TIM3, TIM_IT_CC2);
00153     if(CaptureNumber == 0)
00154     {
00155       /* Get the Input Capture value */
00156       IC3ReadValue1 = TIM_GetCapture2(TIM3);
00157       CaptureNumber = 1;
00158     }
00159     else if(CaptureNumber == 1)
00160     {
00161       /* Get the Input Capture value */
00162       IC3ReadValue2 = TIM_GetCapture2(TIM3); 
00163       
00164       /* Capture computation */
00165       if (IC3ReadValue2 > IC3ReadValue1)
00166       {
00167         Capture = (IC3ReadValue2 - IC3ReadValue1); 
00168       }
00169       else
00170       {
00171         Capture = ((0xFFFF - IC3ReadValue1) + IC3ReadValue2); 
00172       }
00173       /* Frequency computation */ 
00174       TIM3Freq = (uint32_t) SystemCoreClock / Capture;
00175       CaptureNumber = 0;
00176     }
00177   }
00178 }
00179 
00180 /******************************************************************************/
00181 /*                 STM32F10x Peripherals Interrupt Handlers                   */
00182 /*  Add here the Interrupt Handler for the used peripheral(s) (PPP), for the  */
00183 /*  available peripheral interrupt handler's name please refer to the startup */
00184 /*  file (startup_stm32f10x_xx.s).                                            */
00185 /******************************************************************************/
00186 
00187 /**
00188   * @brief  This function handles PPP interrupt request.
00189   * @param  None
00190   * @retval None
00191   */
00192 /*void PPP_IRQHandler(void)
00193 {
00194 }*/
00195 
00196 /**
00197   * @}
00198   */ 
00199 
00200 /**
00201   * @}
00202   */ 
00203 
00204 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32