forkd

Dependencies:   mbed

Fork of LGstaandart by Dmitry Kovalev

Committer:
igor_v
Date:
Sat Jan 30 13:00:39 2016 +0000
Revision:
0:8ad47e2b6f00
Child:
1:f2adcae3d304
2016_01_30;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
igor_v 0:8ad47e2b6f00 1 #include "mathDSP.h"
igor_v 0:8ad47e2b6f00 2 #include "SIP.h"
igor_v 0:8ad47e2b6f00 3 #include "CyclesSync.h"
igor_v 0:8ad47e2b6f00 4 #include "CntrlGLD.h"
igor_v 0:8ad47e2b6f00 5 #include "InputOutput.h"
igor_v 0:8ad47e2b6f00 6 #include "ThermoCalc.h"
igor_v 0:8ad47e2b6f00 7 #include "el_lin.h"
igor_v 0:8ad47e2b6f00 8
igor_v 0:8ad47e2b6f00 9
igor_v 0:8ad47e2b6f00 10 uint32_t Old_Cnt_Vib = 0;
igor_v 0:8ad47e2b6f00 11 uint32_t Old_Cnt = 0;
igor_v 0:8ad47e2b6f00 12 int32_t RefMeand_Cnt_Dif;
igor_v 0:8ad47e2b6f00 13 int32_t PSdif_sum_Vib_32 = 0;
igor_v 0:8ad47e2b6f00 14 __int64 PSdif_sum_Vib_64 = 0;
igor_v 0:8ad47e2b6f00 15 int32_t dif_Curr_32_Ext; //r. ðàçíîñòü (÷èñëî) äëÿ ðåæèìà âíåøíåé çàùåëêè
igor_v 0:8ad47e2b6f00 16 int32_t dif_Curr_32_previous; //e. Previous (in comparison with Dif_Curr_32) number //r. ïðåäûäóùåå (ïî ñðàâíåíèþ ñ Dif_Curr_32) ÷èñëî
igor_v 0:8ad47e2b6f00 17 int32_t temp22=0;
igor_v 0:8ad47e2b6f00 18 //+++++++++++++++++++++++++++++++INPUT DATA++++++++++++++++++++++++++++++++++++++++++++++++
igor_v 0:8ad47e2b6f00 19 uint32_t Curr_Cnt_Vib;
igor_v 0:8ad47e2b6f00 20 uint32_t Cnt_curr;
igor_v 0:8ad47e2b6f00 21
igor_v 0:8ad47e2b6f00 22 //+++++++++++++++++++++++++++++++variables for output++++++++++++++++++++++++++++++++++++++
igor_v 0:8ad47e2b6f00 23 int32_t Dif_Curr_Vib; //e. current difference output for dithering control in LightUp mode and Dither regulator
igor_v 0:8ad47e2b6f00 24 int32_t Dif_Curr_32; //e. current difference without dithering for dithering control
igor_v 0:8ad47e2b6f00 25
igor_v 0:8ad47e2b6f00 26 #if (defined GLOBALRATE)//íå âõîäèò
igor_v 0:8ad47e2b6f00 27
igor_v 0:8ad47e2b6f00 28 //variables for rate mode
igor_v 0:8ad47e2b6f00 29 int32_t cntPls_sum_32;
igor_v 0:8ad47e2b6f00 30 ñññ int32_t last_Cnt_Plus;
igor_v 0:8ad47e2b6f00 31 int32_t dif_sum_32;
igor_v 0:8ad47e2b6f00 32 int32_t Cnt_Pls;
igor_v 0:8ad47e2b6f00 33 int32_t Cnt_Mns;
igor_v 0:8ad47e2b6f00 34 int32_t preLast_Cnt_Plus;
igor_v 0:8ad47e2b6f00 35 // uint32_t sumCnt_Mns = 0;
igor_v 0:8ad47e2b6f00 36 //uint32_t sumCnt_Pls = 0;
igor_v 0:8ad47e2b6f00 37 extern int32_t dif_cur_test[30];
igor_v 0:8ad47e2b6f00 38 extern unsigned ii;
igor_v 0:8ad47e2b6f00 39 uint32_t halfPeriod = 0;
igor_v 0:8ad47e2b6f00 40 #endif
igor_v 0:8ad47e2b6f00 41
igor_v 0:8ad47e2b6f00 42 void ResetBitsOfWord(int * x32, int truncate_bits)
igor_v 0:8ad47e2b6f00 43 {
igor_v 0:8ad47e2b6f00 44 int hi_part;
igor_v 0:8ad47e2b6f00 45
igor_v 0:8ad47e2b6f00 46 hi_part = *x32 >> truncate_bits;
igor_v 0:8ad47e2b6f00 47 *x32 -= hi_part << truncate_bits; //r. îñòàâëÿåì ìëàäøèå 16 áèò
igor_v 0:8ad47e2b6f00 48 }
igor_v 0:8ad47e2b6f00 49 /******************************************************************************
igor_v 0:8ad47e2b6f00 50 ** Function name: interpolation
igor_v 0:8ad47e2b6f00 51 **
igor_v 0:8ad47e2b6f00 52 ** Descriptions: êîëè÷åñòâî èòåðïîëÿöèé äî ïîÿâëåíèÿ âíåøíåé çàùåëêè
igor_v 0:8ad47e2b6f00 53 **
igor_v 0:8ad47e2b6f00 54 ** Returned value: Number in moment of external latch appearing
igor_v 0:8ad47e2b6f00 55 ** parameters: y_curr - current number, y_prev - number at one cycle before time
igor_v 0:8ad47e2b6f00 56 ** x_interp - moment of external latch appearing,
igor_v 0:8ad47e2b6f00 57
igor_v 0:8ad47e2b6f00 58 ** Precision of interpolation is 1/8 of impulse (3 digits after point in 14.18 format)
igor_v 0:8ad47e2b6f00 59 ******************************************************************************/
igor_v 0:8ad47e2b6f00 60 int interpolation(int y_curr, int x_interp)
igor_v 0:8ad47e2b6f00 61 {
igor_v 0:8ad47e2b6f00 62 __int64 temp,temp3;
igor_v 0:8ad47e2b6f00 63
igor_v 0:8ad47e2b6f00 64 temp = (__int64)y_curr *(__int64)x_interp;
igor_v 0:8ad47e2b6f00 65 temp /= PrevPeriod; // void ServiceTime(void) ||| PrevPeriod = LPC_PWM1->MR0; ||| (CyclesSync.c)
igor_v 0:8ad47e2b6f00 66
igor_v 0:8ad47e2b6f00 67 temp3 = (__int64)y_curr *(__int64)(x_interp+1);
igor_v 0:8ad47e2b6f00 68 temp3 /= PrevPeriod;
igor_v 0:8ad47e2b6f00 69 temp22 = (int)temp3;
igor_v 0:8ad47e2b6f00 70
igor_v 0:8ad47e2b6f00 71 return ((int)temp);
igor_v 0:8ad47e2b6f00 72 } // interpolation
igor_v 0:8ad47e2b6f00 73 /******************************************************************************
igor_v 0:8ad47e2b6f00 74 ** Function name: clc_Pulses
igor_v 0:8ad47e2b6f00 75 **
igor_v 0:8ad47e2b6f00 76 ** Descriptions: Processing of information from SPOI
igor_v 0:8ad47e2b6f00 77 **
igor_v 0:8ad47e2b6f00 78 ** parameters: None
igor_v 0:8ad47e2b6f00 79 ** Returned value: None
igor_v 0:8ad47e2b6f00 80 **
igor_v 0:8ad47e2b6f00 81 ******************************************************************************/
igor_v 0:8ad47e2b6f00 82
igor_v 0:8ad47e2b6f00 83 void clc_Pulses()
igor_v 0:8ad47e2b6f00 84 {
igor_v 0:8ad47e2b6f00 85
igor_v 0:8ad47e2b6f00 86 #if (!defined GLOBALRATE)
igor_v 0:8ad47e2b6f00 87 static int32_t cntPls_sum_32;
igor_v 0:8ad47e2b6f00 88 static int32_t last_Cnt_Plus;
igor_v 0:8ad47e2b6f00 89 static int32_t dif_sum_32;
igor_v 0:8ad47e2b6f00 90 static int32_t Cnt_Pls;
igor_v 0:8ad47e2b6f00 91 static int32_t Cnt_Mns;
igor_v 0:8ad47e2b6f00 92 static int32_t preLast_Cnt_Plus;
igor_v 0:8ad47e2b6f00 93 #endif
igor_v 0:8ad47e2b6f00 94
igor_v 0:8ad47e2b6f00 95 Dif_Curr_Vib = Curr_Cnt_Vib - Old_Cnt_Vib; //Âû÷èñëåíèå ïðèðàùåíèÿ òåêóùåãî ñ÷åò÷èêà èìïóëüñîâ.
igor_v 0:8ad47e2b6f00 96
igor_v 0:8ad47e2b6f00 97 Old_Cnt_Vib = Curr_Cnt_Vib; //ñîõðàíåíèå òåêóùåãî ñ÷åò÷èêà èìïóëüñîâ äëÿ ñëåäóþùåãî öèêëà èçìåðåíèé
igor_v 0:8ad47e2b6f00 98
igor_v 0:8ad47e2b6f00 99
igor_v 0:8ad47e2b6f00 100 Cnt_Overload(Dif_Curr_Vib, INT32MAX_DIV2, INT32MIN_DIV2); //ïðîâåðêà íà ïåðåïîëíåíèå (Dif_Curr_Vib).
igor_v 0:8ad47e2b6f00 101 // Uin UpSat DwnSat
igor_v 0:8ad47e2b6f00 102
igor_v 0:8ad47e2b6f00 103 //#define Cnt_Overload(Uin, UpSat, DwnSat)
igor_v 0:8ad47e2b6f00 104 /* if (Uin > UpSat)
igor_v 0:8ad47e2b6f00 105
igor_v 0:8ad47e2b6f00 106 {
igor_v 0:8ad47e2b6f00 107 Uin -= INT32_MAX;
igor_v 0:8ad47e2b6f00 108 }
igor_v 0:8ad47e2b6f00 109 if (Uin < DwnSat)
igor_v 0:8ad47e2b6f00 110 {
igor_v 0:8ad47e2b6f00 111 Uin += INT32_MAX;
igor_v 0:8ad47e2b6f00 112 } */
igor_v 0:8ad47e2b6f00 113
igor_v 0:8ad47e2b6f00 114
igor_v 0:8ad47e2b6f00 115 Dif_Curr_32 = VibroReduce(Dif_Curr_Vib << SHIFT_TO_FRACT); // Òî÷íîñòü ôèëüòðàöèè 1/(2^18)
igor_v 0:8ad47e2b6f00 116
igor_v 0:8ad47e2b6f00 117
igor_v 0:8ad47e2b6f00 118
igor_v 0:8ad47e2b6f00 119
igor_v 0:8ad47e2b6f00 120 switch (RgConB) //r. äîïîëíèòåëüíûé ðåãèñòð óïðàâëåíèÿ
igor_v 0:8ad47e2b6f00 121 {
igor_v 0:8ad47e2b6f00 122 case RATE_VIBRO_1: //r. ðàçíîñòü âèáðîñ÷åò÷èêîâ ïîñëå ôèëüòðà ñêîëüçÿùíãî ñðåäíåãî
igor_v 0:8ad47e2b6f00 123
igor_v 0:8ad47e2b6f00 124 if (Latch_Rdy) //e. latch has arrived
igor_v 0:8ad47e2b6f00 125 {
igor_v 0:8ad47e2b6f00 126 //dif_Curr_32_Ext ðàçíîñòü (÷èñëî) äëÿ ðåæèìà âíåøíåé çàùåëêè
igor_v 0:8ad47e2b6f00 127 dif_Curr_32_Ext = interpolation(Dif_Curr_32, LatchPhase ); //èíòåðïîëÿöèÿ
igor_v 0:8ad47e2b6f00 128 Output.Str.Tmp_Out[2] = (int)((Curr_Cnt_Vib>>16)& 0xffff);
igor_v 0:8ad47e2b6f00 129 Output.Str.Tmp_Out[3] = (int)(Curr_Cnt_Vib & 0xffff);
igor_v 0:8ad47e2b6f00 130 //r. äîáàâëÿåì ê íàêîïëåííîé ñóììå èíòåðïîëèðîâàííûé îòñ÷åò âíåøíåé çàùåëêè
igor_v 0:8ad47e2b6f00 131 PSdif_sum_Vib_32 += dif_Curr_32_Ext;
igor_v 0:8ad47e2b6f00 132 PSdif_sum_Vib_64 += dif_Curr_32_Ext; //e. receive last data
igor_v 0:8ad47e2b6f00 133 //count--;
igor_v 0:8ad47e2b6f00 134
igor_v 0:8ad47e2b6f00 135 //r. ïîäãîòîâèòü ÷èñëî äëÿ âûäà÷è
igor_v 0:8ad47e2b6f00 136 Output.Str.BINS_dif = PSdif_sum_Vib_32 - TermoCompens_Sum; //r. èç íàêîïëåííîãî ÷èñëà âû÷èòàåì íàêîïëåííóþ òåðìîêîìïåíñàöèîííóþ ñîñòàâëÿþùóþ
igor_v 0:8ad47e2b6f00 137 Output.Str.PS_dif = Output.Str.BINS_dif >> 16;
igor_v 0:8ad47e2b6f00 138 LatchPhase = INT32_MAX; //INT32_MAX=2147483647 //in Latch_Event it's indicator of latch appearing
igor_v 0:8ad47e2b6f00 139 Output.Str.SF_dif = PSdif_sum_Vib_64;
igor_v 0:8ad47e2b6f00 140 TermoCompens_Sum = 0; //r. îáíóëÿåì íàêîïëåííóþ òåðìîêîìïåíñàöèþ äëÿ íà÷àëà íîâîãî öèêëà íàêîïëåíèÿ
igor_v 0:8ad47e2b6f00 141
igor_v 0:8ad47e2b6f00 142 if ((Device_Mode == DM_EXT_LATCH_DELTA_BINS_PULSE)||((Device_Mode == DM_EXT_LATCH_DELTA_SF_PULSE) && Ext_Latch_ResetEnable))
igor_v 0:8ad47e2b6f00 143 {
igor_v 0:8ad47e2b6f00 144 PSdif_sum_Vib_32 = 0; //r. èíèöèàëèçèðîâàòü íîâûé öèêë èçìåðåíèÿ ïî çàùåëêå
igor_v 0:8ad47e2b6f00 145 PSdif_sum_Vib_64 = 0;
igor_v 0:8ad47e2b6f00 146 }
igor_v 0:8ad47e2b6f00 147 else
igor_v 0:8ad47e2b6f00 148 ResetBitsOfWord(&PSdif_sum_Vib_32, 16);
igor_v 0:8ad47e2b6f00 149
igor_v 0:8ad47e2b6f00 150 dif_Curr_32_Ext = Dif_Curr_32 - temp22;//dif_Curr_32_Ext;
igor_v 0:8ad47e2b6f00 151
igor_v 0:8ad47e2b6f00 152 PSdif_sum_Vib_32 += dif_Curr_32_Ext; // preserve rest of counters difference for next measure cycle: PSdif_sum_Vib_32 += Dif_Curr_32 - dif_Curr_32_Ext;
igor_v 0:8ad47e2b6f00 153 PSdif_sum_Vib_64 += dif_Curr_32_Ext; //ñîõðàíèòü îñòàëüíûå ñ÷åò÷èêè ðàçíèöû äëÿ ñëåäóþùåãî òàêòà öèêëà
igor_v 0:8ad47e2b6f00 154
igor_v 0:8ad47e2b6f00 155 }
igor_v 0:8ad47e2b6f00 156 else //r. çàùåëêè íà íàñòîÿùèé ìîìåíò íå áûëî
igor_v 0:8ad47e2b6f00 157 {
igor_v 0:8ad47e2b6f00 158 //r. ïðîäîëæàåì íàêàïëèâàòü ñóììó èç âíóòðåííèõ îòñ÷åòîâ
igor_v 0:8ad47e2b6f00 159 PSdif_sum_Vib_32 += Dif_Curr_32; // PSdif_sum_Vib_32 += Dif_Curr_32 ;
igor_v 0:8ad47e2b6f00 160 PSdif_sum_Vib_64 += Dif_Curr_32; //e. sum for scale factor measurement mode
igor_v 0:8ad47e2b6f00 161 }
igor_v 0:8ad47e2b6f00 162
igor_v 0:8ad47e2b6f00 163 dif_Curr_32_previous = Dif_Curr_32; //r. çàïîìèíàåì ïðåäûäóùåå ÷èñëî
igor_v 0:8ad47e2b6f00 164 break;
igor_v 0:8ad47e2b6f00 165
igor_v 0:8ad47e2b6f00 166 case RATE_REPER_OR_REFMEANDR:
igor_v 0:8ad47e2b6f00 167
igor_v 0:8ad47e2b6f00 168 if (data_Rdy & HALF_PERIOD) //e. calculate Cnt_Mns or Cnt_Pls
igor_v 0:8ad47e2b6f00 169 {
igor_v 0:8ad47e2b6f00 170 RefMeand_Cnt_Dif = Cnt_curr - Old_Cnt;
igor_v 0:8ad47e2b6f00 171 Old_Cnt = Cnt_curr;
igor_v 0:8ad47e2b6f00 172 // LPC_GPIO2->FIOCLR = 0x10;
igor_v 0:8ad47e2b6f00 173 Cnt_Overload(RefMeand_Cnt_Dif, INT32MAX_DIV2, INT32MIN_DIV2);
igor_v 0:8ad47e2b6f00 174
igor_v 0:8ad47e2b6f00 175 if (LPC_QEI->STAT) //e. "+" direction //r. ñòàëè âðàùàòüñÿ â "+" ñòîðîíó
igor_v 0:8ad47e2b6f00 176 {
igor_v 0:8ad47e2b6f00 177 //sumCnt_Mns += -RefMeand_Cnt_Dif; //e. accumulation during 1 sec
igor_v 0:8ad47e2b6f00 178 Cnt_Mns = RefMeand_Cnt_Dif;
igor_v 0:8ad47e2b6f00 179 }
igor_v 0:8ad47e2b6f00 180 else
igor_v 0:8ad47e2b6f00 181 {
igor_v 0:8ad47e2b6f00 182 //r. ñòàëè âðàùàòüñÿ â "-" ñòîðîíó
igor_v 0:8ad47e2b6f00 183 //sumCnt_Pls += RefMeand_Cnt_Dif; //e. accumulation during 1 sec
igor_v 0:8ad47e2b6f00 184 Cnt_Pls = -RefMeand_Cnt_Dif;
igor_v 0:8ad47e2b6f00 185 }
igor_v 0:8ad47e2b6f00 186
igor_v 0:8ad47e2b6f00 187 // UART1_SendByte((dif_sum_32>>8) & 0xff);
igor_v 0:8ad47e2b6f00 188 // UART1_SendByte((dif_sum_32) & 0xff);
igor_v 0:8ad47e2b6f00 189
igor_v 0:8ad47e2b6f00 190 if (data_Rdy & WHOLE_PERIOD) //e. period of vibro elapsed
igor_v 0:8ad47e2b6f00 191 {
igor_v 0:8ad47e2b6f00 192 // LPC_GPIO2->FIOSET = 0x10;
igor_v 0:8ad47e2b6f00 193 last_Cnt_Plus = Cnt_Pls;
igor_v 0:8ad47e2b6f00 194 dif_sum_32 += Cnt_Pls - Cnt_Mns;
igor_v 0:8ad47e2b6f00 195 }
igor_v 0:8ad47e2b6f00 196 data_Rdy &= ~RESET_PERIOD;
igor_v 0:8ad47e2b6f00 197 }
igor_v 0:8ad47e2b6f00 198 if (Latch_Rdy) //e it's time for output
igor_v 0:8ad47e2b6f00 199 {
igor_v 0:8ad47e2b6f00 200 LatchPhase = INT32_MAX;
igor_v 0:8ad47e2b6f00 201
igor_v 0:8ad47e2b6f00 202 Output.Str.Tmp_Out[2] = (int)((Curr_Cnt_Vib>>16)& 0xffff);
igor_v 0:8ad47e2b6f00 203 Output.Str.Tmp_Out[3] = (int)(Curr_Cnt_Vib & 0xffff);
igor_v 0:8ad47e2b6f00 204
igor_v 0:8ad47e2b6f00 205 cntPls_sum_32 += last_Cnt_Plus - preLast_Cnt_Plus;
igor_v 0:8ad47e2b6f00 206
igor_v 0:8ad47e2b6f00 207 Output.Str.Cnt_Dif = dif_sum_32;
igor_v 0:8ad47e2b6f00 208 Output.Str.Cnt_Dif += cntPls_sum_32 >> 1;
igor_v 0:8ad47e2b6f00 209
igor_v 0:8ad47e2b6f00 210 dif_sum_32 = 0; //r. è ñáðîñèòü ðåãèñòðû íàêîïëåíèÿ
igor_v 0:8ad47e2b6f00 211 ResetBitsOfWord(&cntPls_sum_32, 1); //r. îñòàâëÿåì ìëàäøèé ðàçðÿä, ÷òîáû íå òåðÿëàñü òî÷íîñòü ïðè ñóììèðîâàíèè
igor_v 0:8ad47e2b6f00 212 preLast_Cnt_Plus = last_Cnt_Plus; //r. òåêóùèé ïîñëåäíèé îòñ÷åò ñòàë ïðåäûäóùèì
igor_v 0:8ad47e2b6f00 213
igor_v 0:8ad47e2b6f00 214 Output.Str.Cnt_Mns = Cnt_Mns;//sumCnt_Mns; //e. rewrite accumulated data to output
igor_v 0:8ad47e2b6f00 215 Output.Str.Cnt_Pls = Cnt_Pls;//sumCnt_Pls;
igor_v 0:8ad47e2b6f00 216
igor_v 0:8ad47e2b6f00 217 //sumCnt_Mns = 0; //e. prepare for new accumulation
igor_v 0:8ad47e2b6f00 218 //sumCnt_Pls = 0;
igor_v 0:8ad47e2b6f00 219 }
igor_v 0:8ad47e2b6f00 220 break; // RATE_REPER_OR_REFMEANDR
igor_v 0:8ad47e2b6f00 221 }
igor_v 0:8ad47e2b6f00 222 //e. WP_scope1, WP_scope2 - variables for control in the Rate3 mode //r. WP_scope1, WP_scope2 - ïåðåìåííûå äëÿ êîíòðîëÿ â ðåæèìå rate3
igor_v 0:8ad47e2b6f00 223 Output.Str.WP_scope1 = Dif_Curr_Vib;
igor_v 0:8ad47e2b6f00 224 Output.Str.WP_scope2 = (Dif_Curr_32 >> (SHIFT_TO_FRACT-2)); //r. 2 äðîáíûõ ðàçðÿäà îñòàâëÿåì äëÿ áîëüøåé íàãëÿäíîñòè ïðè àíàëèçå ñèãíàëà rate3
igor_v 0:8ad47e2b6f00 225 }
igor_v 0:8ad47e2b6f00 226 // clc_Pulses
igor_v 0:8ad47e2b6f00 227
igor_v 0:8ad47e2b6f00 228
igor_v 0:8ad47e2b6f00 229 /******************************************************************************
igor_v 0:8ad47e2b6f00 230 ** Function name: SOI_Init
igor_v 0:8ad47e2b6f00 231 **
igor_v 0:8ad47e2b6f00 232 ** Descriptions: Quadrature encoder initialization.
igor_v 0:8ad47e2b6f00 233 **
igor_v 0:8ad47e2b6f00 234 ** parameters: None
igor_v 0:8ad47e2b6f00 235 ** Returned value: None
igor_v 0:8ad47e2b6f00 236 **
igor_v 0:8ad47e2b6f00 237 ******************************************************************************/
igor_v 0:8ad47e2b6f00 238 void SOI_Init(void)
igor_v 0:8ad47e2b6f00 239 {
igor_v 0:8ad47e2b6f00 240 LPC_SC->PCONP |= (1<<18);//0x00040000; âêëþ÷åíèå êâàäðàòóðíîãî ýíêîäåðà.
igor_v 0:8ad47e2b6f00 241 LPC_SC->PCLKSEL1 |= 0x00000001; // âûáîð ÷àñòîòû äëÿ êâ.ý. CLK=100MHz
igor_v 0:8ad47e2b6f00 242 LPC_PINCON->PINSEL3 &= ~0x4100;
igor_v 0:8ad47e2b6f00 243 LPC_PINCON->PINSEL3 |= 0x4100; //P1.20, p1.23 óñòàíîâèòü êàê âõîäû êâ.ý
igor_v 0:8ad47e2b6f00 244 LPC_PINCON->PINMODE3 |= 0x3C300; //P1.20, p1.23, p1.24 ??are pulled-down??(ïðèòÿíóòü ê ïèòàíèþ)????
igor_v 0:8ad47e2b6f00 245
igor_v 0:8ad47e2b6f00 246 LPC_QEI->MAXPOS = MAX_QEI_CNT; //LPC_QEI->"ðåãèñòîð ìàêñèìàëüíîãî ïîëîæåíèÿ" = 2147483646
igor_v 0:8ad47e2b6f00 247 LPC_QEI->FILTER = 2; // ôèëüòð( ?? )
igor_v 0:8ad47e2b6f00 248 LPC_QEI->CON = 0xF; //ñáðîñèòü â íîëü âñå ñ÷åò÷èêè êâ.ý. (ñêîðîñòü, íàïðàâëåíèå, ïîçèöèþ è òä)
igor_v 0:8ad47e2b6f00 249 LPC_QEI->CONF = (0<<2) |(0<<1); //Quadrature inputs, no inverting,only A pulses are counted
igor_v 0:8ad47e2b6f00 250
igor_v 0:8ad47e2b6f00 251 LPC_QEI->CLR = 0x1fff; //r. ñáðîñèòü âñå ïðåðûâàíèÿ
igor_v 0:8ad47e2b6f00 252 LPC_QEI->IEC = 0x1fff; //r. çàïðåòèòü ïðåðûâàíèå ïðè èçìåíåíèè íàïðàâëåíèÿ
igor_v 0:8ad47e2b6f00 253
igor_v 0:8ad47e2b6f00 254 NVIC_SetPriority(QEI_IRQn, 0);
igor_v 0:8ad47e2b6f00 255 NVIC_EnableIRQ(QEI_IRQn);
igor_v 0:8ad47e2b6f00 256 return;
igor_v 0:8ad47e2b6f00 257 }
igor_v 0:8ad47e2b6f00 258
igor_v 0:8ad47e2b6f00 259
igor_v 0:8ad47e2b6f00 260 /******************************************************************************
igor_v 0:8ad47e2b6f00 261 ** End Of File
igor_v 0:8ad47e2b6f00 262 ******************************************************************************/
igor_v 0:8ad47e2b6f00 263