STM8S/A Standard Peripherals Firmware Library: stm8s_it.c Source File

STM8S/A

STM8S_StdPeriph_Examples/TIM1/TIM1_Sinewave_Generation/stm8s_it.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file     stm8s_it.c
00004   * @author   MCD Application Team
00005   * @version  V2.2.0
00006   * @date     30-September-2014
00007   * @brief    Main Interrupt Service Routines.
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
00012   *
00013   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
00014   * You may not use this file except in compliance with the License.
00015   * You may obtain a copy of the License at:
00016   *
00017   *        http://www.st.com/software_license_agreement_liberty_v2
00018   *
00019   * Unless required by applicable law or agreed to in writing, software 
00020   * distributed under the License is distributed on an "AS IS" BASIS, 
00021   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00022   * See the License for the specific language governing permissions and
00023   * limitations under the License.
00024   *
00025   ******************************************************************************
00026   */ 
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm8s_it.h"
00030 #include "main.h"
00031 
00032 extern __IO MySin_Typedef sin ;
00033 extern __IO uint8_t counter;
00034 /* Private typedef -----------------------------------------------------------*/
00035 /* Private define ------------------------------------------------------------*/
00036 /* Private macro -------------------------------------------------------------*/
00037 /* Private variables ---------------------------------------------------------*/
00038 /* Private function prototypes -----------------------------------------------*/
00039 /* Private functions ---------------------------------------------------------*/
00040 /* Public functions ----------------------------------------------------------*/
00041 
00042 /** @addtogroup TIM1_Sinewave_Generation
00043   * @{
00044   */
00045 #ifdef _COSMIC_
00046 /**
00047   * @brief  Dummy interrupt routine
00048   * @param  None
00049   * @retval None
00050   */
00051 INTERRUPT_HANDLER(NonHandledInterrupt, 25)
00052 {
00053   /* In order to detect unexpected events during development,
00054      it is recommended to set a breakpoint on the following instruction.
00055   */
00056 }
00057 #endif /*_COSMIC_*/
00058 
00059 /**
00060   * @brief  TRAP interrupt routine
00061   * @param  None
00062   * @retval None
00063   */
00064 INTERRUPT_HANDLER_TRAP(TRAP_IRQHandler)
00065 {
00066   /* In order to detect unexpected events during development,
00067      it is recommended to set a breakpoint on the following instruction.
00068   */
00069 }
00070 /**
00071   * @brief  Top Level Interrupt routine
00072   * @param  None
00073   * @retval None
00074   */
00075 INTERRUPT_HANDLER(TLI_IRQHandler, 0)
00076 {
00077   /* In order to detect unexpected events during development,
00078      it is recommended to set a breakpoint on the following instruction.
00079   */
00080 }
00081 
00082 /**
00083   * @brief  Auto Wake Up Interrupt routine
00084   * @param  None
00085   * @retval None
00086   */
00087 INTERRUPT_HANDLER(AWU_IRQHandler, 1)
00088 {
00089   /* In order to detect unexpected events during development,
00090      it is recommended to set a breakpoint on the following instruction.
00091   */
00092 }
00093 
00094 /**
00095   * @brief  Clock Controller Interrupt routine
00096   * @param  None
00097   * @retval None
00098   */
00099 INTERRUPT_HANDLER(CLK_IRQHandler, 2)
00100 {
00101   /* In order to detect unexpected events during development,
00102      it is recommended to set a breakpoint on the following instruction.
00103   */
00104 }
00105 
00106 /**
00107   * @brief  External Interrupt PORTA Interrupt routine
00108   * @param  None
00109   * @retval None
00110   */
00111 INTERRUPT_HANDLER(EXTI_PORTA_IRQHandler, 3)
00112 {
00113   /* In order to detect unexpected events during development,
00114      it is recommended to set a breakpoint on the following instruction.
00115   */
00116 }
00117 
00118 /**
00119   * @brief  External Interrupt PORTB Interrupt routine
00120   * @param  None
00121   * @retval None
00122   */
00123 INTERRUPT_HANDLER(EXTI_PORTB_IRQHandler, 4)
00124 {
00125   /* In order to detect unexpected events during development,
00126      it is recommended to set a breakpoint on the following instruction.
00127   */
00128 }
00129 
00130 /**
00131   * @brief  External Interrupt PORTC Interrupt routine
00132   * @param  None
00133   * @retval None
00134   */
00135 INTERRUPT_HANDLER(EXTI_PORTC_IRQHandler, 5)
00136 {
00137   /* In order to detect unexpected events during development,
00138      it is recommended to set a breakpoint on the following instruction.
00139   */
00140 }
00141 
00142 /**
00143   * @brief  External Interrupt PORTD Interrupt routine
00144   * @param  None
00145   * @retval None
00146   */
00147 INTERRUPT_HANDLER(EXTI_PORTD_IRQHandler, 6)
00148 {
00149   /* In order to detect unexpected events during development,
00150      it is recommended to set a breakpoint on the following instruction.
00151   */
00152 }
00153 
00154 /**
00155   * @brief  External Interrupt PORTE Interrupt routine
00156   * @param  None
00157   * @retval None
00158   */
00159 INTERRUPT_HANDLER(EXTI_PORTE_IRQHandler, 7)
00160 {
00161   /* In order to detect unexpected events during development,
00162      it is recommended to set a breakpoint on the following instruction.
00163   */
00164 }
00165 #ifdef STM8S903
00166 /**
00167   * @brief  External Interrupt PORTF Interrupt routine
00168   * @param  None
00169   * @retval None
00170   */
00171  INTERRUPT_HANDLER(EXTI_PORTF_IRQHandler, 8)
00172 {
00173   /* In order to detect unexpected events during development,
00174      it is recommended to set a breakpoint on the following instruction.
00175   */
00176 }
00177 #endif /*STM8S903*/
00178 
00179 #if defined (STM8S208) || defined (STM8AF52Ax)
00180 /**
00181   * @brief CAN RX Interrupt routine.
00182   * @param  None
00183   * @retval None
00184   */
00185  INTERRUPT_HANDLER(CAN_RX_IRQHandler, 8)
00186 {
00187   /* In order to detect unexpected events during development,
00188      it is recommended to set a breakpoint on the following instruction.
00189   */
00190 }
00191 
00192 /**
00193   * @brief  CAN TX Interrupt routine
00194   * @param  None
00195   * @retval None
00196   */
00197  INTERRUPT_HANDLER(CAN_TX_IRQHandler, 9)
00198 {
00199   /* In order to detect unexpected events during development,
00200      it is recommended to set a breakpoint on the following instruction.
00201   */
00202 }
00203 #endif /*STM8S208 || STM8AF52Ax */
00204 
00205 /**
00206   * @brief  SPI Interrupt routine
00207   * @param  None
00208   * @retval None
00209   */
00210 INTERRUPT_HANDLER(SPI_IRQHandler, 10)
00211 {
00212   /* In order to detect unexpected events during development,
00213      it is recommended to set a breakpoint on the following instruction.
00214   */
00215 }
00216 
00217 /**
00218   * @brief  Timer1 Update/Overflow/Trigger/Break Interrupt routine
00219   * @param  None
00220   * @retval None
00221   */
00222 INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
00223 {
00224   uint8_t PWM_Value = 0;
00225  if (counter >= COUNTER)               
00226   { 
00227     /* Reset the counter value*/
00228     counter = 0;
00229     /* Upper half cycle of sine wave */
00230     if (sin.Up == TRUE)
00231     {
00232       /* Load the duty cycle register for upper half cycle of sine wave.*/ 
00233       /* This is achieved by  adding sample values into AVERAGE_AMP.*/
00234       PWM_Value = (uint8_t)(AVERAGE_AMP + sin.Value[sin.Index]);
00235     }
00236     else 
00237     {
00238       /* Lower half cycle of sine wave */ 
00239       /* Load the duty cycle register for lower  half cycle of sine wave. */ 
00240       /* This is achieved by   subtracting sample values into AVERAGE_AMP. */    
00241       PWM_Value = (uint8_t)(AVERAGE_AMP - sin.Value[sin.Index]);
00242     }
00243     TIM1_SetCompare1(PWM_Value);
00244     /*Increment the index for pointing to wardsnext sample value to be loaded */
00245     sin.Index++;
00246     if (sin.Index == nbr_of_samples_half) 
00247     {
00248       /* Reset the index value */
00249       sin.Index = 0;
00250       /* Lower half sin wave is activated if previously it was upper half and vice-versa */
00251       sin.Up = (bool)(~sin.Up);
00252     } 
00253   }
00254   /* Increment the counter value at each overflow interrupt */
00255   counter++;
00256 
00257   TIM1_ClearITPendingBit(TIM1_IT_UPDATE);
00258 }
00259 
00260 /**
00261   * @brief  Timer1 Capture/Compare Interrupt routine
00262   * @param  None
00263   * @retval None
00264   */
00265 INTERRUPT_HANDLER(TIM1_CAP_COM_IRQHandler, 12)
00266 {
00267   /* In order to detect unexpected events during development,
00268      it is recommended to set a breakpoint on the following instruction.
00269   */
00270 }
00271 
00272 #ifdef STM8S903
00273 /**
00274   * @brief  Timer5 Update/Overflow/Break/Trigger Interrupt routine
00275   * @param  None
00276   * @retval None
00277   */
00278  INTERRUPT_HANDLER(TIM5_UPD_OVF_BRK_TRG_IRQHandler, 13)
00279 {
00280   /* In order to detect unexpected events during development,
00281      it is recommended to set a breakpoint on the following instruction.
00282   */
00283 }
00284 /**
00285   * @brief  Timer5 Capture/Compare Interrupt routine
00286   * @param  None
00287   * @retval None
00288   */
00289  INTERRUPT_HANDLER(TIM5_CAP_COM_IRQHandler, 14)
00290 {
00291   /* In order to detect unexpected events during development,
00292      it is recommended to set a breakpoint on the following instruction.
00293   */
00294 }
00295 
00296 #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
00297 /**
00298   * @brief  Timer2 Update/Overflow/Break Interrupt routine
00299   * @param  None
00300   * @retval None
00301   */
00302  INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
00303 {
00304   /* In order to detect unexpected events during development,
00305      it is recommended to set a breakpoint on the following instruction.
00306   */
00307 }
00308 
00309 /**
00310   * @brief  Timer2 Capture/Compare Interrupt routine
00311   * @param  None
00312   * @retval None
00313   */
00314  INTERRUPT_HANDLER(TIM2_CAP_COM_IRQHandler, 14)
00315 {
00316   /* In order to detect unexpected events during development,
00317      it is recommended to set a breakpoint on the following instruction.
00318   */
00319 }
00320 #endif /*STM8S903*/
00321 
00322 #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S105) || \
00323     defined(STM8S005) ||  defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8AF626x)
00324 /**
00325   * @brief Timer3 Update/Overflow/Break Interrupt routine.
00326   * @param  None
00327   * @retval None
00328   */
00329  INTERRUPT_HANDLER(TIM3_UPD_OVF_BRK_IRQHandler, 15)
00330 {
00331   /* In order to detect unexpected events during development,
00332      it is recommended to set a breakpoint on the following instruction.
00333   */
00334 }
00335 
00336 /**
00337   * @brief  Timer3 Capture/Compare Interrupt routine
00338   * @param  None
00339   * @retval None
00340   */
00341  INTERRUPT_HANDLER(TIM3_CAP_COM_IRQHandler, 16)
00342 {
00343   /* In order to detect unexpected events during development,
00344      it is recommended to set a breakpoint on the following instruction.
00345   */
00346 }
00347 #endif /*STM8S208, STM8S207 or STM8S105 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
00348 
00349 #if defined (STM8S208) || defined(STM8S207) || defined(STM8S007) || defined(STM8S103) || \
00350     defined(STM8S003) ||  defined (STM8AF62Ax) || defined (STM8AF52Ax) || defined (STM8S903)
00351 /**
00352   * @brief  UART1 TX Interrupt routine
00353   * @param  None
00354   * @retval None
00355   */
00356  INTERRUPT_HANDLER(UART1_TX_IRQHandler, 17)
00357 {
00358   /* In order to detect unexpected events during development,
00359      it is recommended to set a breakpoint on the following instruction.
00360   */
00361 }
00362 
00363 /**
00364   * @brief  UART1 RX Interrupt routine
00365   * @param  None
00366   * @retval None
00367   */
00368  INTERRUPT_HANDLER(UART1_RX_IRQHandler, 18)
00369 {
00370   /* In order to detect unexpected events during development,
00371      it is recommended to set a breakpoint on the following instruction.
00372   */
00373 }
00374 #endif /*STM8S105*/
00375 
00376 /**
00377   * @brief  I2C Interrupt routine
00378   * @param  None
00379   * @retval None
00380   */
00381 INTERRUPT_HANDLER(I2C_IRQHandler, 19)
00382 {
00383   /* In order to detect unexpected events during development,
00384      it is recommended to set a breakpoint on the following instruction.
00385   */
00386 }
00387 
00388 #if defined(STM8S105) || defined(STM8S005) ||  defined (STM8AF626x)
00389 /**
00390   * @brief  UART2 TX interrupt routine.
00391   * @param  None
00392   * @retval None
00393   */
00394  INTERRUPT_HANDLER(UART2_TX_IRQHandler, 20)
00395 {
00396     /* In order to detect unexpected events during development,
00397        it is recommended to set a breakpoint on the following instruction.
00398     */
00399   }
00400 
00401 /**
00402   * @brief  UART2 RX interrupt routine.
00403   * @param  None
00404   * @retval None
00405   */
00406  INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
00407 {
00408     /* In order to detect unexpected events during development,
00409        it is recommended to set a breakpoint on the following instruction.
00410     */
00411   }
00412 #endif /* STM8S105*/
00413 
00414 #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
00415 /**
00416   * @brief  UART3 TX interrupt routine.
00417   * @param  None
00418   * @retval None
00419   */
00420  INTERRUPT_HANDLER(UART3_TX_IRQHandler, 20)
00421 {
00422     /* In order to detect unexpected events during development,
00423        it is recommended to set a breakpoint on the following instruction.
00424     */
00425   }
00426 
00427 /**
00428   * @brief  UART3 RX interrupt routine.
00429   * @param  None
00430   * @retval None
00431   */
00432  INTERRUPT_HANDLER(UART3_RX_IRQHandler, 21)
00433 {
00434     /* In order to detect unexpected events during development,
00435        it is recommended to set a breakpoint on the following instruction.
00436     */
00437   }
00438 #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
00439 
00440 #if defined(STM8S207) || defined(STM8S007) || defined(STM8S208) || defined (STM8AF52Ax) || defined (STM8AF62Ax)
00441 /**
00442   * @brief  ADC2 interrupt routine.
00443   * @param  None
00444   * @retval None
00445   */
00446  INTERRUPT_HANDLER(ADC2_IRQHandler, 22)
00447 {
00448 
00449     /* In order to detect unexpected events during development,
00450        it is recommended to set a breakpoint on the following instruction.
00451     */
00452     return;
00453 
00454 }
00455 #else /*STM8S105, STM8S103 or STM8S903 or STM8AF626x */
00456 /**
00457   * @brief  ADC1 interrupt routine.
00458   * @param  None
00459   * @retval None
00460   */
00461  INTERRUPT_HANDLER(ADC1_IRQHandler, 22)
00462 {
00463 
00464     /* In order to detect unexpected events during development,
00465        it is recommended to set a breakpoint on the following instruction.
00466     */
00467     return;
00468 
00469 }
00470 #endif /*STM8S208 or STM8S207 or STM8AF52Ax or STM8AF62Ax */
00471 
00472 #ifdef STM8S903
00473 /**
00474   * @brief  Timer6 Update/Overflow/Trigger Interrupt routine
00475   * @param  None
00476   * @retval None
00477   */
00478 INTERRUPT_HANDLER(TIM6_UPD_OVF_TRG_IRQHandler, 23)
00479 {
00480   /* In order to detect unexpected events during development,
00481      it is recommended to set a breakpoint on the following instruction.
00482   */
00483 }
00484 #else /*STM8S208, STM8S207, STM8S105 or STM8S103 or STM8AF62Ax or STM8AF52Ax or STM8AF626x */
00485 /**
00486   * @brief  Timer4 Update/Overflow Interrupt routine
00487   * @param  None
00488   * @retval None
00489   */
00490  INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23)
00491 {
00492   /* In order to detect unexpected events during development,
00493      it is recommended to set a breakpoint on the following instruction.
00494   */
00495 }
00496 #endif /*STM8S903*/
00497 
00498 /**
00499   * @brief  Eeprom EEC Interrupt routine
00500   * @param  None
00501   * @retval None
00502   */
00503 INTERRUPT_HANDLER(EEPROM_EEC_IRQHandler, 24)
00504 {
00505   /* In order to detect unexpected events during development,
00506      it is recommended to set a breakpoint on the following instruction.
00507   */
00508 }
00509 
00510 /**
00511   * @}
00512   */
00513 
00514 
00515 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com