These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
TIMER/PWMSignal/pwm_signal.c@0:bf7b9fba3924, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 05:38:56 2011 +0000
- Revision:
- 0:bf7b9fba3924
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:bf7b9fba3924 | 1 | /***********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 2 | * @file pwm_signal.c |
frank26080115 | 0:bf7b9fba3924 | 3 | * @purpose This example use TIMERs to generate 4 PWM signals with |
frank26080115 | 0:bf7b9fba3924 | 4 | * different duty cycle |
frank26080115 | 0:bf7b9fba3924 | 5 | * @version 2.0 |
frank26080115 | 0:bf7b9fba3924 | 6 | * @date 21. May. 2010 |
frank26080115 | 0:bf7b9fba3924 | 7 | * @author NXP MCU SW Application Team |
frank26080115 | 0:bf7b9fba3924 | 8 | *--------------------------------------------------------------------- |
frank26080115 | 0:bf7b9fba3924 | 9 | * Software that is described herein is for illustrative purposes only |
frank26080115 | 0:bf7b9fba3924 | 10 | * which provides customers with programming information regarding the |
frank26080115 | 0:bf7b9fba3924 | 11 | * products. This software is supplied "AS IS" without any warranties. |
frank26080115 | 0:bf7b9fba3924 | 12 | * NXP Semiconductors assumes no responsibility or liability for the |
frank26080115 | 0:bf7b9fba3924 | 13 | * use of the software, conveys no license or title under any patent, |
frank26080115 | 0:bf7b9fba3924 | 14 | * copyright, or mask work right to the product. NXP Semiconductors |
frank26080115 | 0:bf7b9fba3924 | 15 | * reserves the right to make changes in the software without |
frank26080115 | 0:bf7b9fba3924 | 16 | * notification. NXP Semiconductors also make no representation or |
frank26080115 | 0:bf7b9fba3924 | 17 | * warranty that such application will be suitable for the specified |
frank26080115 | 0:bf7b9fba3924 | 18 | * use without further testing or modification. |
frank26080115 | 0:bf7b9fba3924 | 19 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 20 | #include "lpc17xx_libcfg.h" |
frank26080115 | 0:bf7b9fba3924 | 21 | #include "debug_frmwrk.h" |
frank26080115 | 0:bf7b9fba3924 | 22 | #include "lpc17xx_gpio.h" |
frank26080115 | 0:bf7b9fba3924 | 23 | #include "lpc17xx_pinsel.h" |
frank26080115 | 0:bf7b9fba3924 | 24 | #include "lpc17xx_timer.h" |
frank26080115 | 0:bf7b9fba3924 | 25 | |
frank26080115 | 0:bf7b9fba3924 | 26 | /* Example group ----------------------------------------------------------- */ |
frank26080115 | 0:bf7b9fba3924 | 27 | /** @defgroup TIMER_PWMSignal PWMSignal |
frank26080115 | 0:bf7b9fba3924 | 28 | * @ingroup TIMER_Examples |
frank26080115 | 0:bf7b9fba3924 | 29 | * @{ |
frank26080115 | 0:bf7b9fba3924 | 30 | */ |
frank26080115 | 0:bf7b9fba3924 | 31 | |
frank26080115 | 0:bf7b9fba3924 | 32 | /************************** PRIVATE VARIABLES *************************/ |
frank26080115 | 0:bf7b9fba3924 | 33 | uint8_t menu[]= |
frank26080115 | 0:bf7b9fba3924 | 34 | "********************************************************************************\n\r" |
frank26080115 | 0:bf7b9fba3924 | 35 | "Hello NXP Semiconductors \n\r" |
frank26080115 | 0:bf7b9fba3924 | 36 | "System Tick demo \n\r" |
frank26080115 | 0:bf7b9fba3924 | 37 | "\t - MCU: LPC17xx \n\r" |
frank26080115 | 0:bf7b9fba3924 | 38 | "\t - Core: ARM CORTEX-M3 \n\r" |
frank26080115 | 0:bf7b9fba3924 | 39 | "\t - Communicate via: UART0 - 115200 bps \n\r" |
frank26080115 | 0:bf7b9fba3924 | 40 | "This example used TIMERs to generate 4 PWM signals with different duty cycles \n\r" |
frank26080115 | 0:bf7b9fba3924 | 41 | "********************************************************************************\n\r"; |
frank26080115 | 0:bf7b9fba3924 | 42 | FunctionalState PWM0_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 43 | FunctionalState PWM1_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 44 | FunctionalState PWM2_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 45 | FunctionalState PWM3_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 46 | |
frank26080115 | 0:bf7b9fba3924 | 47 | TIM_TIMERCFG_Type TIM_ConfigStruct; |
frank26080115 | 0:bf7b9fba3924 | 48 | TIM_MATCHCFG_Type TIM_MatchConfigStruct; |
frank26080115 | 0:bf7b9fba3924 | 49 | |
frank26080115 | 0:bf7b9fba3924 | 50 | /************************** PRIVATE FUNCTIONS *************************/ |
frank26080115 | 0:bf7b9fba3924 | 51 | void TIMER0_IRQHandler(void); |
frank26080115 | 0:bf7b9fba3924 | 52 | void TIMER1_IRQHandler(void); |
frank26080115 | 0:bf7b9fba3924 | 53 | void TIMER2_IRQHandler(void); |
frank26080115 | 0:bf7b9fba3924 | 54 | void TIMER3_IRQHandler(void); |
frank26080115 | 0:bf7b9fba3924 | 55 | |
frank26080115 | 0:bf7b9fba3924 | 56 | void print_menu(void); |
frank26080115 | 0:bf7b9fba3924 | 57 | |
frank26080115 | 0:bf7b9fba3924 | 58 | /*----------------- INTERRUPT SERVICE ROUTINES --------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 59 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 60 | * @brief TIMER0 interrupt handler |
frank26080115 | 0:bf7b9fba3924 | 61 | * @param None |
frank26080115 | 0:bf7b9fba3924 | 62 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 63 | ***********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 64 | void TIMER0_IRQHandler(void) |
frank26080115 | 0:bf7b9fba3924 | 65 | { |
frank26080115 | 0:bf7b9fba3924 | 66 | //duty cycle = 12.5% |
frank26080115 | 0:bf7b9fba3924 | 67 | TIM_Cmd(LPC_TIM0,DISABLE); |
frank26080115 | 0:bf7b9fba3924 | 68 | TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); |
frank26080115 | 0:bf7b9fba3924 | 69 | TIM_ResetCounter(LPC_TIM0); |
frank26080115 | 0:bf7b9fba3924 | 70 | if((PWM0_State == ENABLE)) |
frank26080115 | 0:bf7b9fba3924 | 71 | { |
frank26080115 | 0:bf7b9fba3924 | 72 | TIM_UpdateMatchValue(LPC_TIM0, 0, 100); |
frank26080115 | 0:bf7b9fba3924 | 73 | PWM0_State = DISABLE; |
frank26080115 | 0:bf7b9fba3924 | 74 | } |
frank26080115 | 0:bf7b9fba3924 | 75 | else |
frank26080115 | 0:bf7b9fba3924 | 76 | { |
frank26080115 | 0:bf7b9fba3924 | 77 | TIM_UpdateMatchValue(LPC_TIM0, 0, 700); |
frank26080115 | 0:bf7b9fba3924 | 78 | PWM0_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 79 | } |
frank26080115 | 0:bf7b9fba3924 | 80 | TIM_Cmd(LPC_TIM0,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 81 | } |
frank26080115 | 0:bf7b9fba3924 | 82 | |
frank26080115 | 0:bf7b9fba3924 | 83 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 84 | * @brief TIMER1 interrupt handler |
frank26080115 | 0:bf7b9fba3924 | 85 | * @param None |
frank26080115 | 0:bf7b9fba3924 | 86 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 87 | ***********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 88 | void TIMER1_IRQHandler(void) |
frank26080115 | 0:bf7b9fba3924 | 89 | { |
frank26080115 | 0:bf7b9fba3924 | 90 | //duty cycle = 25% |
frank26080115 | 0:bf7b9fba3924 | 91 | TIM_Cmd(LPC_TIM1,DISABLE); |
frank26080115 | 0:bf7b9fba3924 | 92 | TIM_ClearIntPending(LPC_TIM1, TIM_MR0_INT); |
frank26080115 | 0:bf7b9fba3924 | 93 | TIM_ResetCounter(LPC_TIM1); |
frank26080115 | 0:bf7b9fba3924 | 94 | if((PWM1_State == ENABLE)) |
frank26080115 | 0:bf7b9fba3924 | 95 | { |
frank26080115 | 0:bf7b9fba3924 | 96 | TIM_UpdateMatchValue(LPC_TIM1,0, 200); |
frank26080115 | 0:bf7b9fba3924 | 97 | PWM1_State = DISABLE; |
frank26080115 | 0:bf7b9fba3924 | 98 | } |
frank26080115 | 0:bf7b9fba3924 | 99 | else |
frank26080115 | 0:bf7b9fba3924 | 100 | { |
frank26080115 | 0:bf7b9fba3924 | 101 | TIM_UpdateMatchValue(LPC_TIM1,0, 600); |
frank26080115 | 0:bf7b9fba3924 | 102 | PWM1_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 103 | } |
frank26080115 | 0:bf7b9fba3924 | 104 | TIM_Cmd(LPC_TIM1,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 105 | } |
frank26080115 | 0:bf7b9fba3924 | 106 | |
frank26080115 | 0:bf7b9fba3924 | 107 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 108 | * @brief TIMER2 interrupt handler |
frank26080115 | 0:bf7b9fba3924 | 109 | * @param None |
frank26080115 | 0:bf7b9fba3924 | 110 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 111 | ***********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 112 | void TIMER2_IRQHandler(void) |
frank26080115 | 0:bf7b9fba3924 | 113 | { |
frank26080115 | 0:bf7b9fba3924 | 114 | //duty cycle = 37,5% |
frank26080115 | 0:bf7b9fba3924 | 115 | TIM_Cmd(LPC_TIM2,DISABLE); |
frank26080115 | 0:bf7b9fba3924 | 116 | TIM_ClearIntPending(LPC_TIM2, TIM_MR0_INT); |
frank26080115 | 0:bf7b9fba3924 | 117 | TIM_ResetCounter(LPC_TIM2); |
frank26080115 | 0:bf7b9fba3924 | 118 | if((PWM2_State == ENABLE)) |
frank26080115 | 0:bf7b9fba3924 | 119 | { |
frank26080115 | 0:bf7b9fba3924 | 120 | TIM_UpdateMatchValue(LPC_TIM2,0, 300); |
frank26080115 | 0:bf7b9fba3924 | 121 | PWM2_State = DISABLE; |
frank26080115 | 0:bf7b9fba3924 | 122 | } |
frank26080115 | 0:bf7b9fba3924 | 123 | else |
frank26080115 | 0:bf7b9fba3924 | 124 | { |
frank26080115 | 0:bf7b9fba3924 | 125 | TIM_UpdateMatchValue(LPC_TIM2,0, 500); |
frank26080115 | 0:bf7b9fba3924 | 126 | PWM2_State = ENABLE; |
frank26080115 | 0:bf7b9fba3924 | 127 | } |
frank26080115 | 0:bf7b9fba3924 | 128 | TIM_Cmd(LPC_TIM2,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 129 | } |
frank26080115 | 0:bf7b9fba3924 | 130 | |
frank26080115 | 0:bf7b9fba3924 | 131 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 132 | * @brief TIMER3 interrupt handler |
frank26080115 | 0:bf7b9fba3924 | 133 | * @param None |
frank26080115 | 0:bf7b9fba3924 | 134 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 135 | ***********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 136 | void TIMER3_IRQHandler(void) |
frank26080115 | 0:bf7b9fba3924 | 137 | { |
frank26080115 | 0:bf7b9fba3924 | 138 | //duty cycle = 50% |
frank26080115 | 0:bf7b9fba3924 | 139 | TIM_Cmd(LPC_TIM3,DISABLE); |
frank26080115 | 0:bf7b9fba3924 | 140 | TIM_ClearIntPending(LPC_TIM3, TIM_MR0_INT); |
frank26080115 | 0:bf7b9fba3924 | 141 | TIM_ResetCounter(LPC_TIM3); |
frank26080115 | 0:bf7b9fba3924 | 142 | TIM_Cmd(LPC_TIM3,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 143 | } |
frank26080115 | 0:bf7b9fba3924 | 144 | |
frank26080115 | 0:bf7b9fba3924 | 145 | |
frank26080115 | 0:bf7b9fba3924 | 146 | /*-------------------------PRIVATE FUNCTIONS------------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 147 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 148 | * @brief Print Welcome menu |
frank26080115 | 0:bf7b9fba3924 | 149 | * @param[in] none |
frank26080115 | 0:bf7b9fba3924 | 150 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 151 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 152 | void print_menu(void) |
frank26080115 | 0:bf7b9fba3924 | 153 | { |
frank26080115 | 0:bf7b9fba3924 | 154 | _DBG(menu); |
frank26080115 | 0:bf7b9fba3924 | 155 | } |
frank26080115 | 0:bf7b9fba3924 | 156 | |
frank26080115 | 0:bf7b9fba3924 | 157 | |
frank26080115 | 0:bf7b9fba3924 | 158 | /*-------------------------MAIN FUNCTION------------------------------*/ |
frank26080115 | 0:bf7b9fba3924 | 159 | /*********************************************************************//** |
frank26080115 | 0:bf7b9fba3924 | 160 | * @brief c_entry: Main TIMER program body |
frank26080115 | 0:bf7b9fba3924 | 161 | * @param[in] None |
frank26080115 | 0:bf7b9fba3924 | 162 | * @return int |
frank26080115 | 0:bf7b9fba3924 | 163 | **********************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 164 | int c_entry (void) |
frank26080115 | 0:bf7b9fba3924 | 165 | { |
frank26080115 | 0:bf7b9fba3924 | 166 | PINSEL_CFG_Type PinCfg; |
frank26080115 | 0:bf7b9fba3924 | 167 | |
frank26080115 | 0:bf7b9fba3924 | 168 | /* Initialize debug via UART0 |
frank26080115 | 0:bf7b9fba3924 | 169 | * 115200bps |
frank26080115 | 0:bf7b9fba3924 | 170 | * 8 data bit |
frank26080115 | 0:bf7b9fba3924 | 171 | * No parity |
frank26080115 | 0:bf7b9fba3924 | 172 | * 1 stop bit |
frank26080115 | 0:bf7b9fba3924 | 173 | * No flow control |
frank26080115 | 0:bf7b9fba3924 | 174 | */ |
frank26080115 | 0:bf7b9fba3924 | 175 | debug_frmwrk_init(); |
frank26080115 | 0:bf7b9fba3924 | 176 | |
frank26080115 | 0:bf7b9fba3924 | 177 | // print welcome screen |
frank26080115 | 0:bf7b9fba3924 | 178 | print_menu(); |
frank26080115 | 0:bf7b9fba3924 | 179 | |
frank26080115 | 0:bf7b9fba3924 | 180 | /* Select pin: |
frank26080115 | 0:bf7b9fba3924 | 181 | * P1.28: MAT0.0 |
frank26080115 | 0:bf7b9fba3924 | 182 | * P1.22: MAT1.0 |
frank26080115 | 0:bf7b9fba3924 | 183 | * P0.6: MAT2.0 |
frank26080115 | 0:bf7b9fba3924 | 184 | * P0.10: MAT3.0 |
frank26080115 | 0:bf7b9fba3924 | 185 | */ |
frank26080115 | 0:bf7b9fba3924 | 186 | PinCfg.Funcnum = 3; |
frank26080115 | 0:bf7b9fba3924 | 187 | PinCfg.OpenDrain = 0; |
frank26080115 | 0:bf7b9fba3924 | 188 | PinCfg.Pinmode = 0; |
frank26080115 | 0:bf7b9fba3924 | 189 | PinCfg.Portnum = 1; |
frank26080115 | 0:bf7b9fba3924 | 190 | PinCfg.Pinnum = 28; |
frank26080115 | 0:bf7b9fba3924 | 191 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 192 | PinCfg.Pinnum = 22; |
frank26080115 | 0:bf7b9fba3924 | 193 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 194 | PinCfg.Portnum = 0; |
frank26080115 | 0:bf7b9fba3924 | 195 | PinCfg.Pinnum = 6; |
frank26080115 | 0:bf7b9fba3924 | 196 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 197 | PinCfg.Pinnum = 10; |
frank26080115 | 0:bf7b9fba3924 | 198 | PINSEL_ConfigPin(&PinCfg); |
frank26080115 | 0:bf7b9fba3924 | 199 | |
frank26080115 | 0:bf7b9fba3924 | 200 | // Initialize 4 timers, prescale count time of 100uS |
frank26080115 | 0:bf7b9fba3924 | 201 | TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_USVAL; |
frank26080115 | 0:bf7b9fba3924 | 202 | TIM_ConfigStruct.PrescaleValue = 100; |
frank26080115 | 0:bf7b9fba3924 | 203 | |
frank26080115 | 0:bf7b9fba3924 | 204 | TIM_Init(LPC_TIM0, TIM_TIMER_MODE,&TIM_ConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 205 | TIM_Init(LPC_TIM1, TIM_TIMER_MODE,&TIM_ConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 206 | TIM_Init(LPC_TIM2, TIM_TIMER_MODE,&TIM_ConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 207 | TIM_Init(LPC_TIM3, TIM_TIMER_MODE,&TIM_ConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 208 | |
frank26080115 | 0:bf7b9fba3924 | 209 | // Configure 4 match channels |
frank26080115 | 0:bf7b9fba3924 | 210 | // use channel 0, MR0 |
frank26080115 | 0:bf7b9fba3924 | 211 | TIM_MatchConfigStruct.MatchChannel = 0; |
frank26080115 | 0:bf7b9fba3924 | 212 | // Enable interrupt when MR0 matches the value in TC register |
frank26080115 | 0:bf7b9fba3924 | 213 | TIM_MatchConfigStruct.IntOnMatch = TRUE; |
frank26080115 | 0:bf7b9fba3924 | 214 | //Enable reset on MR0: TIMER will reset if MR0 matches it |
frank26080115 | 0:bf7b9fba3924 | 215 | TIM_MatchConfigStruct.ResetOnMatch = TRUE; |
frank26080115 | 0:bf7b9fba3924 | 216 | //Stop on MR0 if MR0 matches it |
frank26080115 | 0:bf7b9fba3924 | 217 | TIM_MatchConfigStruct.StopOnMatch = FALSE; |
frank26080115 | 0:bf7b9fba3924 | 218 | //Toggle MR0 pin if MR0 matches it |
frank26080115 | 0:bf7b9fba3924 | 219 | TIM_MatchConfigStruct.ExtMatchOutputType = TIM_EXTMATCH_TOGGLE; |
frank26080115 | 0:bf7b9fba3924 | 220 | // Set Match value |
frank26080115 | 0:bf7b9fba3924 | 221 | TIM_MatchConfigStruct.MatchValue = 700; |
frank26080115 | 0:bf7b9fba3924 | 222 | // Set configuration for Tim_MatchConfig |
frank26080115 | 0:bf7b9fba3924 | 223 | TIM_ConfigMatch(LPC_TIM0,&TIM_MatchConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 224 | TIM_MatchConfigStruct.MatchValue = 600; |
frank26080115 | 0:bf7b9fba3924 | 225 | TIM_ConfigMatch(LPC_TIM1,&TIM_MatchConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 226 | TIM_MatchConfigStruct.MatchValue = 500; |
frank26080115 | 0:bf7b9fba3924 | 227 | TIM_ConfigMatch(LPC_TIM2,&TIM_MatchConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 228 | TIM_MatchConfigStruct.MatchValue = 800; |
frank26080115 | 0:bf7b9fba3924 | 229 | TIM_ConfigMatch(LPC_TIM3,&TIM_MatchConfigStruct); |
frank26080115 | 0:bf7b9fba3924 | 230 | |
frank26080115 | 0:bf7b9fba3924 | 231 | /* preemption = 1, sub-priority = 1 */ |
frank26080115 | 0:bf7b9fba3924 | 232 | NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01)); |
frank26080115 | 0:bf7b9fba3924 | 233 | /* Enable interrupt for timer 0 */ |
frank26080115 | 0:bf7b9fba3924 | 234 | NVIC_EnableIRQ(TIMER0_IRQn); |
frank26080115 | 0:bf7b9fba3924 | 235 | // To start timer 0 |
frank26080115 | 0:bf7b9fba3924 | 236 | TIM_Cmd(LPC_TIM0,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 237 | |
frank26080115 | 0:bf7b9fba3924 | 238 | /* preemption = 1, sub-priority = 1 */ |
frank26080115 | 0:bf7b9fba3924 | 239 | NVIC_SetPriority(TIMER1_IRQn, ((0x01<<3)|0x02)); |
frank26080115 | 0:bf7b9fba3924 | 240 | /* Enable interrupt for timer 1 */ |
frank26080115 | 0:bf7b9fba3924 | 241 | NVIC_EnableIRQ(TIMER1_IRQn); |
frank26080115 | 0:bf7b9fba3924 | 242 | // To start timer 1 |
frank26080115 | 0:bf7b9fba3924 | 243 | TIM_Cmd(LPC_TIM1,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 244 | |
frank26080115 | 0:bf7b9fba3924 | 245 | /* preemption = 1, sub-priority = 1 */ |
frank26080115 | 0:bf7b9fba3924 | 246 | NVIC_SetPriority(TIMER2_IRQn, ((0x01<<3)|0x03)); |
frank26080115 | 0:bf7b9fba3924 | 247 | /* Enable interrupt for timer 1 */ |
frank26080115 | 0:bf7b9fba3924 | 248 | NVIC_EnableIRQ(TIMER2_IRQn); |
frank26080115 | 0:bf7b9fba3924 | 249 | // To start timer 1 |
frank26080115 | 0:bf7b9fba3924 | 250 | TIM_Cmd(LPC_TIM2,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 251 | |
frank26080115 | 0:bf7b9fba3924 | 252 | /* preemption = 1, sub-priority = 1 */ |
frank26080115 | 0:bf7b9fba3924 | 253 | NVIC_SetPriority(TIMER3_IRQn, ((0x01<<3)|0x04)); |
frank26080115 | 0:bf7b9fba3924 | 254 | /* Enable interrupt for timer 1 */ |
frank26080115 | 0:bf7b9fba3924 | 255 | NVIC_EnableIRQ(TIMER3_IRQn); |
frank26080115 | 0:bf7b9fba3924 | 256 | // To start timer 1 |
frank26080115 | 0:bf7b9fba3924 | 257 | TIM_Cmd(LPC_TIM3,ENABLE); |
frank26080115 | 0:bf7b9fba3924 | 258 | |
frank26080115 | 0:bf7b9fba3924 | 259 | while(1); |
frank26080115 | 0:bf7b9fba3924 | 260 | return (1); |
frank26080115 | 0:bf7b9fba3924 | 261 | } |
frank26080115 | 0:bf7b9fba3924 | 262 | |
frank26080115 | 0:bf7b9fba3924 | 263 | |
frank26080115 | 0:bf7b9fba3924 | 264 | /* With ARM and GHS toolsets, the entry point is main() - this will |
frank26080115 | 0:bf7b9fba3924 | 265 | allow the linker to generate wrapper code to setup stacks, allocate |
frank26080115 | 0:bf7b9fba3924 | 266 | heap area, and initialize and copy code and data segments. For GNU |
frank26080115 | 0:bf7b9fba3924 | 267 | toolsets, the entry point is through __start() in the crt0_gnu.asm |
frank26080115 | 0:bf7b9fba3924 | 268 | file, and that startup code will setup stacks and data */ |
frank26080115 | 0:bf7b9fba3924 | 269 | int main(void) |
frank26080115 | 0:bf7b9fba3924 | 270 | { |
frank26080115 | 0:bf7b9fba3924 | 271 | return c_entry(); |
frank26080115 | 0:bf7b9fba3924 | 272 | } |
frank26080115 | 0:bf7b9fba3924 | 273 | |
frank26080115 | 0:bf7b9fba3924 | 274 | #ifdef DEBUG |
frank26080115 | 0:bf7b9fba3924 | 275 | /******************************************************************************* |
frank26080115 | 0:bf7b9fba3924 | 276 | * @brief Reports the name of the source file and the source line number |
frank26080115 | 0:bf7b9fba3924 | 277 | * where the CHECK_PARAM error has occurred. |
frank26080115 | 0:bf7b9fba3924 | 278 | * @param[in] file Pointer to the source file name |
frank26080115 | 0:bf7b9fba3924 | 279 | * @param[in] line assert_param error line source number |
frank26080115 | 0:bf7b9fba3924 | 280 | * @return None |
frank26080115 | 0:bf7b9fba3924 | 281 | *******************************************************************************/ |
frank26080115 | 0:bf7b9fba3924 | 282 | void check_failed(uint8_t *file, uint32_t line) |
frank26080115 | 0:bf7b9fba3924 | 283 | { |
frank26080115 | 0:bf7b9fba3924 | 284 | /* User can add his own implementation to report the file name and line number, |
frank26080115 | 0:bf7b9fba3924 | 285 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
frank26080115 | 0:bf7b9fba3924 | 286 | |
frank26080115 | 0:bf7b9fba3924 | 287 | /* Infinite loop */ |
frank26080115 | 0:bf7b9fba3924 | 288 | while(1); |
frank26080115 | 0:bf7b9fba3924 | 289 | } |
frank26080115 | 0:bf7b9fba3924 | 290 | #endif |
frank26080115 | 0:bf7b9fba3924 | 291 | |
frank26080115 | 0:bf7b9fba3924 | 292 | /* |
frank26080115 | 0:bf7b9fba3924 | 293 | * @} |
frank26080115 | 0:bf7b9fba3924 | 294 | */ |