![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
MTimer.c@228:a8195e1b1123, 2018-01-09 (annotated)
- Committer:
- Kovalev_D
- Date:
- Tue Jan 09 13:19:26 2018 +0000
- Revision:
- 228:a8195e1b1123
- Parent:
- 227:2774b56bfab0
- Child:
- 231:079835d508ef
tryFiltr
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igor_v | 0:8ad47e2b6f00 | 1 | #include "MTimer.h" |
igor_v | 0:8ad47e2b6f00 | 2 | #include "LPC17xx.h" |
igor_v | 0:8ad47e2b6f00 | 3 | #include "MTimer.h" |
igor_v | 0:8ad47e2b6f00 | 4 | #include "vibro.h" |
igor_v | 0:8ad47e2b6f00 | 5 | #include "QEI.h" |
igor_v | 0:8ad47e2b6f00 | 6 | #include "Global.h" |
Kovalev_D | 228:a8195e1b1123 | 7 | #include "string.h" |
igor_v | 0:8ad47e2b6f00 | 8 | #include "SPI.h" |
igor_v | 0:8ad47e2b6f00 | 9 | #include "InputOutput.h" |
Kovalev_D | 228:a8195e1b1123 | 10 | #include "time.h" |
Kovalev_D | 112:4a96133a1311 | 11 | |
Kovalev_D | 197:7a05523bf588 | 12 | unsigned int CountV64=0; |
igor_v | 0:8ad47e2b6f00 | 13 | unsigned int CountV31=0; |
Kovalev_D | 197:7a05523bf588 | 14 | unsigned int CountV255=0; |
Kovalev_D | 215:b58b887fd367 | 15 | unsigned int CountV511=0; |
Kovalev_D | 209:224e7331a061 | 16 | unsigned int f,MODCount=0; |
Kovalev_D | 124:9ae09249f842 | 17 | int loop=0; |
Kovalev_D | 208:19150d2b528f | 18 | int t; |
Kovalev_D | 88:b5c1d9d338d1 | 19 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 20 | /////////////////////EVENT/////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 21 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 22 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 23 | ///////////////////// 1250Hz /////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 24 | ///////////////////////////////////////////////////// |
Kovalev_D | 214:4c70e452c491 | 25 | void Event_1250Hz(void)// событие раз в 1,25 КГц |
Kovalev_D | 214:4c70e452c491 | 26 | { |
Kovalev_D | 214:4c70e452c491 | 27 | if(Event1250Hz) |
Kovalev_D | 214:4c70e452c491 | 28 | { |
Kovalev_D | 214:4c70e452c491 | 29 | Gyro.EvenRate7=1; |
Kovalev_D | 215:b58b887fd367 | 30 | |
Kovalev_D | 214:4c70e452c491 | 31 | Event1250Hz--; |
Kovalev_D | 215:b58b887fd367 | 32 | |
Kovalev_D | 214:4c70e452c491 | 33 | } |
Kovalev_D | 214:4c70e452c491 | 34 | } |
Kovalev_D | 222:7de7b3bf3a1d | 35 | |
Kovalev_D | 222:7de7b3bf3a1d | 36 | |
Kovalev_D | 222:7de7b3bf3a1d | 37 | |
Kovalev_D | 222:7de7b3bf3a1d | 38 | |
Kovalev_D | 222:7de7b3bf3a1d | 39 | void JumpMod(void) |
Kovalev_D | 222:7de7b3bf3a1d | 40 | { |
Kovalev_D | 222:7de7b3bf3a1d | 41 | static int JumpFlag=0; |
Kovalev_D | 222:7de7b3bf3a1d | 42 | switch(JumpFlag) { |
Kovalev_D | 222:7de7b3bf3a1d | 43 | case 0: |
Kovalev_D | 222:7de7b3bf3a1d | 44 | Spi.DAC_B-=Gyro.JumpDelta; |
Kovalev_D | 222:7de7b3bf3a1d | 45 | JumpFlag=1; |
Kovalev_D | 222:7de7b3bf3a1d | 46 | break; |
Kovalev_D | 222:7de7b3bf3a1d | 47 | case 1: |
Kovalev_D | 222:7de7b3bf3a1d | 48 | Spi.DAC_B+=Gyro.JumpDelta; |
Kovalev_D | 222:7de7b3bf3a1d | 49 | JumpFlag=0; |
Kovalev_D | 222:7de7b3bf3a1d | 50 | break; |
Kovalev_D | 222:7de7b3bf3a1d | 51 | } |
Kovalev_D | 222:7de7b3bf3a1d | 52 | |
Kovalev_D | 222:7de7b3bf3a1d | 53 | } |
Kovalev_D | 222:7de7b3bf3a1d | 54 | |
Kovalev_D | 222:7de7b3bf3a1d | 55 | |
Kovalev_D | 214:4c70e452c491 | 56 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 57 | ///////////////////// 1Hz /////////////////////////// |
Kovalev_D | 89:a0d344db227e | 58 | ///////////////////////////////////////////////////// |
Kovalev_D | 222:7de7b3bf3a1d | 59 | |
Kovalev_D | 228:a8195e1b1123 | 60 | |
Kovalev_D | 88:b5c1d9d338d1 | 61 | void Event_1Hz(void)// событие раз в 1 Гц |
Kovalev_D | 222:7de7b3bf3a1d | 62 | { |
Kovalev_D | 228:a8195e1b1123 | 63 | |
Kovalev_D | 228:a8195e1b1123 | 64 | //string ster = 255; |
Kovalev_D | 222:7de7b3bf3a1d | 65 | static int tempdac=0,tempdac1,JumpTimer=0; |
Kovalev_D | 228:a8195e1b1123 | 66 | |
Kovalev_D | 228:a8195e1b1123 | 67 | |
Kovalev_D | 228:a8195e1b1123 | 68 | // unsigned int timer; |
Kovalev_D | 228:a8195e1b1123 | 69 | |
Kovalev_D | 228:a8195e1b1123 | 70 | |
Kovalev_D | 115:e5a230e5af52 | 71 | if (Event1Hz) |
Kovalev_D | 222:7de7b3bf3a1d | 72 | { |
Kovalev_D | 228:a8195e1b1123 | 73 | /* timer = time(NULL); */ |
Kovalev_D | 227:2774b56bfab0 | 74 | |
Kovalev_D | 228:a8195e1b1123 | 75 | |
Kovalev_D | 222:7de7b3bf3a1d | 76 | if(Gyro.RgConA&0x4) JumpTimer=0; |
Kovalev_D | 222:7de7b3bf3a1d | 77 | else |
Kovalev_D | 222:7de7b3bf3a1d | 78 | { |
Kovalev_D | 222:7de7b3bf3a1d | 79 | /*sprintf((Time),"%d %d\r\n",Gyro.RgConA,JumpTimer); |
Kovalev_D | 222:7de7b3bf3a1d | 80 | WriteCon(Time);*/ |
Kovalev_D | 222:7de7b3bf3a1d | 81 | JumpTimer++; |
Kovalev_D | 222:7de7b3bf3a1d | 82 | if(JumpTimer>(Gyro.TimeToJump-1)) |
Kovalev_D | 222:7de7b3bf3a1d | 83 | { |
Kovalev_D | 225:f8fee6c586cc | 84 | Gyro.PLCDelay = GyroP.Str.PLCDelay; |
Kovalev_D | 222:7de7b3bf3a1d | 85 | JumpMod(); |
Kovalev_D | 222:7de7b3bf3a1d | 86 | JumpTimer=0; |
Kovalev_D | 222:7de7b3bf3a1d | 87 | } |
Kovalev_D | 222:7de7b3bf3a1d | 88 | } |
Kovalev_D | 222:7de7b3bf3a1d | 89 | |
Kovalev_D | 222:7de7b3bf3a1d | 90 | |
Kovalev_D | 222:7de7b3bf3a1d | 91 | |
Kovalev_D | 208:19150d2b528f | 92 | Discharg(); |
Kovalev_D | 208:19150d2b528f | 93 | BackLight(); |
Kovalev_D | 208:19150d2b528f | 94 | Gyro.Rate1_Event = 1; |
Kovalev_D | 208:19150d2b528f | 95 | Event1Hz--; |
Kovalev_D | 208:19150d2b528f | 96 | Time1Hz++; |
Kovalev_D | 228:a8195e1b1123 | 97 | |
Kovalev_D | 228:a8195e1b1123 | 98 | |
Kovalev_D | 228:a8195e1b1123 | 99 | /* |
Kovalev_D | 228:a8195e1b1123 | 100 | sprintf((Time),"\r\n %s %d %d ",__DATE__, UItempDate, FtempDate); |
Kovalev_D | 228:a8195e1b1123 | 101 | WriteCon(Time);*/ |
Kovalev_D | 228:a8195e1b1123 | 102 | /*sprintf(Time,"%s %s.",__DATE__, __TIME__ ); //Подготовка даты и времени компиляции |
Kovalev_D | 228:a8195e1b1123 | 103 | WriteCon(Time);*/ |
Kovalev_D | 222:7de7b3bf3a1d | 104 | } |
Kovalev_D | 88:b5c1d9d338d1 | 105 | } |
Kovalev_D | 222:7de7b3bf3a1d | 106 | |
Kovalev_D | 89:a0d344db227e | 107 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 108 | ///////////////////// 1kHz ////////////////////////// |
Kovalev_D | 197:7a05523bf588 | 109 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 110 | void Event_1KHz(void)// событие раз в 1 кГц |
Kovalev_D | 214:4c70e452c491 | 111 | { if (Event1K) |
Kovalev_D | 116:66f1f0ff2dab | 112 | { |
Kovalev_D | 214:4c70e452c491 | 113 | if(Gyro.PLCDelay) Gyro.PLCDelay--; |
Kovalev_D | 88:b5c1d9d338d1 | 114 | Event1K --; |
Kovalev_D | 215:b58b887fd367 | 115 | |
Kovalev_D | 116:66f1f0ff2dab | 116 | Time1K++;//первый ++ работает каждые 125 (event100kHz)второй был в 100 кГц |
Kovalev_D | 209:224e7331a061 | 117 | if (Time1K > 1000) |
Kovalev_D | 115:e5a230e5af52 | 118 | { |
Kovalev_D | 208:19150d2b528f | 119 | Time1K -=1000; |
Kovalev_D | 88:b5c1d9d338d1 | 120 | Event1Hz ++; |
Kovalev_D | 88:b5c1d9d338d1 | 121 | } |
Kovalev_D | 209:224e7331a061 | 122 | |
Kovalev_D | 214:4c70e452c491 | 123 | } |
Kovalev_D | 88:b5c1d9d338d1 | 124 | } |
Kovalev_D | 209:224e7331a061 | 125 | |
Kovalev_D | 222:7de7b3bf3a1d | 126 | void Event_5KHz(void)// событие раз в 5 кГц |
Kovalev_D | 218:b4067cac75c0 | 127 | { |
Kovalev_D | 218:b4067cac75c0 | 128 | int temp=0; |
Kovalev_D | 222:7de7b3bf3a1d | 129 | if (Event5K) |
Kovalev_D | 222:7de7b3bf3a1d | 130 | { |
Kovalev_D | 222:7de7b3bf3a1d | 131 | Gyro.EvenRate5K++; |
Kovalev_D | 222:7de7b3bf3a1d | 132 | Event5K --; |
Kovalev_D | 209:224e7331a061 | 133 | } |
Kovalev_D | 209:224e7331a061 | 134 | } |
Kovalev_D | 124:9ae09249f842 | 135 | void Event_500Hz(void)// событие раз в 500 Гц |
Kovalev_D | 124:9ae09249f842 | 136 | { |
Kovalev_D | 124:9ae09249f842 | 137 | if(Event500Hz) |
Kovalev_D | 225:f8fee6c586cc | 138 | { |
Kovalev_D | 225:f8fee6c586cc | 139 | if(Gyro.Debag2) |
Kovalev_D | 225:f8fee6c586cc | 140 | { |
Kovalev_D | 227:2774b56bfab0 | 141 | sprintf((Time),"%d %d %d\r\n", (0xffff-Spi.DAC_A), ((Spi.DAC_B-0x7fff)&0xffff), BuffADC_128Point[CountV64]); |
Kovalev_D | 225:f8fee6c586cc | 142 | WriteCon(Time); |
Kovalev_D | 227:2774b56bfab0 | 143 | |
Kovalev_D | 225:f8fee6c586cc | 144 | } |
Kovalev_D | 205:775d54fdf646 | 145 | Event500Hz--; |
Kovalev_D | 208:19150d2b528f | 146 | Gyro.Event_500Hz=1;// Event 500Гц выдачи данных для постройки графика управления вибро |
Kovalev_D | 197:7a05523bf588 | 147 | } |
Kovalev_D | 197:7a05523bf588 | 148 | } |
Kovalev_D | 209:224e7331a061 | 149 | void Event_250Hz(void) |
Kovalev_D | 209:224e7331a061 | 150 | { |
Kovalev_D | 209:224e7331a061 | 151 | if(Event250Hz) |
Kovalev_D | 209:224e7331a061 | 152 | { |
Kovalev_D | 218:b4067cac75c0 | 153 | |
Kovalev_D | 209:224e7331a061 | 154 | // Gyro.CuruAngle=0; |
Kovalev_D | 209:224e7331a061 | 155 | Event250Hz--; |
Kovalev_D | 209:224e7331a061 | 156 | MODCount++; |
Kovalev_D | 209:224e7331a061 | 157 | } |
Kovalev_D | 209:224e7331a061 | 158 | } |
Kovalev_D | 89:a0d344db227e | 159 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 160 | ///////////////////// 100kHz ////////////////////////// |
Kovalev_D | 89:a0d344db227e | 161 | ///////////////////////////////////////////////////// |
Kovalev_D | 193:a0fe8bfc97e4 | 162 | void Event_100KHz(void)// событие раз в 100 кГц |
Kovalev_D | 88:b5c1d9d338d1 | 163 | { |
Kovalev_D | 162:44e4ded32c6a | 164 | |
Kovalev_D | 88:b5c1d9d338d1 | 165 | if (Event100K) { |
Kovalev_D | 197:7a05523bf588 | 166 | |
Kovalev_D | 88:b5c1d9d338d1 | 167 | Event100K --; |
Kovalev_D | 197:7a05523bf588 | 168 | |
Kovalev_D | 124:9ae09249f842 | 169 | if (OutBufCon1Count)OutBufCon1Count--; // обратный отсчет для управления ногой и формирование задержки на выдачу |
Kovalev_D | 124:9ae09249f842 | 170 | |
Kovalev_D | 124:9ae09249f842 | 171 | PinCheng(); // чтение регистра состояния выводов(вибро, полсветка, поджиг, LED) и управление выводами. |
Kovalev_D | 88:b5c1d9d338d1 | 172 | } |
Kovalev_D | 88:b5c1d9d338d1 | 173 | } |
Kovalev_D | 89:a0d344db227e | 174 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 175 | //////////////////vibro EVENT//////////////////////// |
Kovalev_D | 89:a0d344db227e | 176 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 177 | void Event_Vibro(void)// событие от вибр |
Kovalev_D | 88:b5c1d9d338d1 | 178 | { |
Kovalev_D | 88:b5c1d9d338d1 | 179 | if (EventVibro) { |
Kovalev_D | 88:b5c1d9d338d1 | 180 | EventVibro --; |
Kovalev_D | 88:b5c1d9d338d1 | 181 | } |
Kovalev_D | 88:b5c1d9d338d1 | 182 | } |
Kovalev_D | 89:a0d344db227e | 183 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 184 | ///////////////////////////////////////////////////// |
Kovalev_D | 89:a0d344db227e | 185 | ///////////////////////////////////////////////////// |
Kovalev_D | 88:b5c1d9d338d1 | 186 | |
Kovalev_D | 88:b5c1d9d338d1 | 187 | |
Kovalev_D | 112:4a96133a1311 | 188 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 189 | ////////////////////////////////////////////////////////TIMER1//////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 190 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 191 | |
Kovalev_D | 112:4a96133a1311 | 192 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 193 | /////////////////////инициализация таймера 1 ///////////////////////// |
Kovalev_D | 112:4a96133a1311 | 194 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 195 | |
Kovalev_D | 112:4a96133a1311 | 196 | unsigned int Init_TIM1 (unsigned int TimerInterval ) |
Kovalev_D | 112:4a96133a1311 | 197 | { |
Kovalev_D | 214:4c70e452c491 | 198 | // LPC_SC->PCLKSEL0 |= (1<<4); |
Kovalev_D | 220:04c54405b82d | 199 | |
Kovalev_D | 112:4a96133a1311 | 200 | LPC_TIM1->MR0 = TimerInterval; |
Kovalev_D | 112:4a96133a1311 | 201 | LPC_TIM1->MCR = 3; /* Interrupt and Reset on MR1 */ |
Kovalev_D | 112:4a96133a1311 | 202 | NVIC_EnableIRQ(TIMER1_IRQn); |
Kovalev_D | 112:4a96133a1311 | 203 | } |
Kovalev_D | 112:4a96133a1311 | 204 | |
Kovalev_D | 112:4a96133a1311 | 205 | |
igor_v | 0:8ad47e2b6f00 | 206 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 207 | /////////////////////////включение таймера 1////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 208 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 209 | void enable_timer1( void ) |
igor_v | 21:bc8c1cec3da6 | 210 | { |
igor_v | 21:bc8c1cec3da6 | 211 | LPC_TIM1->TCR = 1; |
igor_v | 21:bc8c1cec3da6 | 212 | return; |
igor_v | 21:bc8c1cec3da6 | 213 | } |
igor_v | 0:8ad47e2b6f00 | 214 | |
igor_v | 0:8ad47e2b6f00 | 215 | |
igor_v | 0:8ad47e2b6f00 | 216 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 217 | /////////////////////////////////////////////////TIMER2////////////////////////////////////////////////////////////////////////////////// |
igor_v | 0:8ad47e2b6f00 | 218 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 219 | |
igor_v | 0:8ad47e2b6f00 | 220 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 221 | /////////////////////инициализация таймера 2 ///////////////////////// |
igor_v | 0:8ad47e2b6f00 | 222 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 223 | unsigned int Init_TIM2 (void) |
igor_v | 21:bc8c1cec3da6 | 224 | { |
Kovalev_D | 124:9ae09249f842 | 225 | LPC_TIM2->MR0 = 257; |
igor_v | 21:bc8c1cec3da6 | 226 | LPC_TIM2->MCR = 3; /* Interrupt and Reset on MR0 */ |
igor_v | 21:bc8c1cec3da6 | 227 | NVIC_EnableIRQ(TIMER2_IRQn); |
igor_v | 21:bc8c1cec3da6 | 228 | return 1; |
igor_v | 21:bc8c1cec3da6 | 229 | } |
igor_v | 0:8ad47e2b6f00 | 230 | |
igor_v | 21:bc8c1cec3da6 | 231 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 232 | /////////////////////////включение таймера 2////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 233 | ////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 234 | void enable_timer2(void) |
igor_v | 21:bc8c1cec3da6 | 235 | { |
igor_v | 21:bc8c1cec3da6 | 236 | LPC_TIM2->TCR = 1; |
igor_v | 21:bc8c1cec3da6 | 237 | LPC_TIM2->TCR = 0x01; |
igor_v | 21:bc8c1cec3da6 | 238 | } |
igor_v | 21:bc8c1cec3da6 | 239 | |
igor_v | 21:bc8c1cec3da6 | 240 | |
Kovalev_D | 112:4a96133a1311 | 241 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 242 | /////////////////////////прерывание таймера 1////////////////////////// |
Kovalev_D | 112:4a96133a1311 | 243 | ////////////////////////////////////////////////////////////////////// |
Kovalev_D | 215:b58b887fd367 | 244 | __irq void TIMER1_IRQHandler (void)//13.27 kHz(vibro*32) |
Kovalev_D | 205:775d54fdf646 | 245 | { |
Kovalev_D | 208:19150d2b528f | 246 | |
igor_v | 114:5cc38a53d8a7 | 247 | ResetCS(ADC); //prepare ADC for sampling |
Kovalev_D | 112:4a96133a1311 | 248 | SetDAC(DAC); |
Kovalev_D | 208:19150d2b528f | 249 | Global_Time++; |
igor_v | 114:5cc38a53d8a7 | 250 | CountV255++; // инкремент счеттчика |
Kovalev_D | 215:b58b887fd367 | 251 | CountV511++; |
Kovalev_D | 164:6f43f85fdd8d | 252 | CountV255 &= 0xff; // ОБРЕЗАНИЕ СЧЕТЧИКА |
Kovalev_D | 215:b58b887fd367 | 253 | CountV511 &= 0x1ff; |
Kovalev_D | 197:7a05523bf588 | 254 | CountV64 = CountV255 & 0x3f; |
Kovalev_D | 197:7a05523bf588 | 255 | CountV31 = CountV255 & 0x1f; // малый счетчик |
Kovalev_D | 197:7a05523bf588 | 256 | |
Kovalev_D | 112:4a96133a1311 | 257 | D_QEI(); //чтение данных по счетчику |
Kovalev_D | 143:2b15794a6cd2 | 258 | cheng(); // выставление флагов в 32 тактном цикле. |
Kovalev_D | 116:66f1f0ff2dab | 259 | |
Kovalev_D | 116:66f1f0ff2dab | 260 | |
Kovalev_D | 116:66f1f0ff2dab | 261 | SetCS(ADC); //start ADC sampling |
Kovalev_D | 116:66f1f0ff2dab | 262 | ResetDAC(DAC); |
Kovalev_D | 197:7a05523bf588 | 263 | SPI_Exchange(); //Чтение ADC_SPI |
igor_v | 114:5cc38a53d8a7 | 264 | |
Kovalev_D | 214:4c70e452c491 | 265 | LPC_TIM1->IR = 1; |
Kovalev_D | 208:19150d2b528f | 266 | |
Kovalev_D | 112:4a96133a1311 | 267 | } |
Kovalev_D | 112:4a96133a1311 | 268 | |
igor_v | 21:bc8c1cec3da6 | 269 | /////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 270 | /////////////////////////прерывание таймера 2////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 271 | /////////////////////////////////////////////////////////////////////// |
igor_v | 21:bc8c1cec3da6 | 272 | __irq void TIMER2_IRQHandler (void) |
Kovalev_D | 210:b02fa166315d | 273 | { |
Kovalev_D | 213:9953db9543d6 | 274 | /// LoopOn |
igor_v | 21:bc8c1cec3da6 | 275 | LPC_TIM2->IR = 1; |
Kovalev_D | 213:9953db9543d6 | 276 | if (Gyro.UARTFlag) |
Kovalev_D | 213:9953db9543d6 | 277 | { |
Kovalev_D | 213:9953db9543d6 | 278 | if(Time_UART) Time_UART--; |
Kovalev_D | 213:9953db9543d6 | 279 | } |
Kovalev_D | 214:4c70e452c491 | 280 | // |
Kovalev_D | 214:4c70e452c491 | 281 | |
igor_v | 21:bc8c1cec3da6 | 282 | Time_vibro++; |
Kovalev_D | 214:4c70e452c491 | 283 | // VibroOut(); |
Kovalev_D | 112:4a96133a1311 | 284 | Gyro.VibroOutF=1; |
Kovalev_D | 214:4c70e452c491 | 285 | Event100K ++; |
Kovalev_D | 214:4c70e452c491 | 286 | Time1250Hz++; |
Kovalev_D | 197:7a05523bf588 | 287 | Time500Hz++; |
Kovalev_D | 209:224e7331a061 | 288 | Time250Hz++; |
Kovalev_D | 197:7a05523bf588 | 289 | Time100K++; |
Kovalev_D | 222:7de7b3bf3a1d | 290 | Time5K++; |
Kovalev_D | 209:224e7331a061 | 291 | //Time2K++; |
Kovalev_D | 205:775d54fdf646 | 292 | // Time250Hz++; |
Kovalev_D | 214:4c70e452c491 | 293 | |
Kovalev_D | 214:4c70e452c491 | 294 | if (Time1250Hz > 79) |
Kovalev_D | 214:4c70e452c491 | 295 | { |
Kovalev_D | 214:4c70e452c491 | 296 | Time1250Hz -= 80; |
Kovalev_D | 214:4c70e452c491 | 297 | Event1250Hz ++; |
Kovalev_D | 214:4c70e452c491 | 298 | } |
Kovalev_D | 197:7a05523bf588 | 299 | if (Time100K == 100) |
Kovalev_D | 214:4c70e452c491 | 300 | { // LoopOn |
Kovalev_D | 197:7a05523bf588 | 301 | Time100K = 0; |
Kovalev_D | 197:7a05523bf588 | 302 | Event1K ++; |
Kovalev_D | 214:4c70e452c491 | 303 | // LoopOn |
Kovalev_D | 197:7a05523bf588 | 304 | } |
Kovalev_D | 209:224e7331a061 | 305 | |
Kovalev_D | 225:f8fee6c586cc | 306 | if (Time5K > 200000) |
Kovalev_D | 222:7de7b3bf3a1d | 307 | { Time5K = 0; |
Kovalev_D | 225:f8fee6c586cc | 308 | if(Gyro.Debag) |
Kovalev_D | 225:f8fee6c586cc | 309 | { |
Kovalev_D | 225:f8fee6c586cc | 310 | for(int q=0; q<64; q++) |
Kovalev_D | 225:f8fee6c586cc | 311 | { |
Kovalev_D | 225:f8fee6c586cc | 312 | sprintf((Time),"%i \r\n", ModArraySin [q]); |
Kovalev_D | 225:f8fee6c586cc | 313 | WriteCon(Time); |
Kovalev_D | 225:f8fee6c586cc | 314 | } |
Kovalev_D | 225:f8fee6c586cc | 315 | } |
Kovalev_D | 222:7de7b3bf3a1d | 316 | Event5K ++; |
Kovalev_D | 209:224e7331a061 | 317 | } |
Kovalev_D | 209:224e7331a061 | 318 | |
Kovalev_D | 197:7a05523bf588 | 319 | if (Time500Hz > 200) |
Kovalev_D | 208:19150d2b528f | 320 | { // LoopOn |
Kovalev_D | 197:7a05523bf588 | 321 | Time500Hz -= 200; |
Kovalev_D | 208:19150d2b528f | 322 | Event500Hz ++; |
Kovalev_D | 197:7a05523bf588 | 323 | } |
Kovalev_D | 209:224e7331a061 | 324 | |
Kovalev_D | 209:224e7331a061 | 325 | if (Time250Hz > 6) |
Kovalev_D | 209:224e7331a061 | 326 | { // LoopOn |
Kovalev_D | 209:224e7331a061 | 327 | Time250Hz -= 6; |
Kovalev_D | 209:224e7331a061 | 328 | Event250Hz ++; |
Kovalev_D | 209:224e7331a061 | 329 | } |
Kovalev_D | 210:b02fa166315d | 330 | |
Kovalev_D | 213:9953db9543d6 | 331 | //LoopOff |
igor_v | 21:bc8c1cec3da6 | 332 | } |