| поискавой системы для электроныых деталей |
|
AN1530 датащи(PDF) 9 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN1530 датащи(HTML) 9 Page - STMicroelectronics |
|
9 / 12 page ![]() 9/12 ACCURATE TIMEBASE FOR LOW-COST ST7 APPLICATIONS WITH INTERNAL RC... /****************************************************************************** Enable MCC to watch the real internal RC oscillator frequency ******************************************************************************/ MCC_Init(MCC_DEFAULT); MCC_Init(MCO_ENABLE); /****************************************************************************** TIMER A Library called to capture the rising edge at the pin PF4 ******************************************************************************/ TIMERA_Init(TIMER_FCPU_2); /*Timer clock is fcpu/2=1 MHz at fosc=4MHz*/ TIMERA_ICAP_Mode(TIMER_ICAP_1,TIMER_EDGE_0); TIMERA_IT_Enable(TIMER_ICAP_IT_ENABLE); EnableInterrupts; /****************************************************************************** Loop to capture 8 samples and to do averaging of it with using glitch filter algorithm to protect the wrong signal capture ******************************************************************************/ for (i=0;i<8;i++) /*averaging done for 8 samples*/ { while (cap != 2); /*wait loop for two captures*/ /*management the possibility of overflow of counter*/ if (capture2 < capture1) { capture2 = ((0xffff - capture1) + capture2); } else { capture2 = (capture2 - capture1); } capture2 = capture2 >> 3; /**********************Glitch filtering Algorithm **********************/ if (i==0) { capture_range = capture2; } fraction = fraction + capture2; if((capture2>(1.1*capture_range))||(capture2<(0.9 * capture_range))) { fraction =0; i=0; } capture1=capture2=cap=0; } /*fraction = Measured RC frequency/assumed internal RC Frequency (here 4 MHz)*/ fraction = ((float)fraction/0x4e20); Nop; /****************************************************************************** TIMER PARAMETER CALIBRATION ******************************************************************************/ #ifdef TIMERB_PWM_CAL /********** Timer PWM generation for 5 KHz frequency*****************/ /****************************************************************************** 100 value to get 100 microcesconds at 2MHz fcpu, equation is used as per ST72F521 datasheet ******************************************************************************/ PWM_CNT = (int)(200 * fraction); /*numerator calculation*/ |
|
|
ссылки URL |
| Вашему бизинису помогли Аллдатащит? [ DONATE ] |
Что такое Аллдатащит | реклама | контакт | Конфиденциальность | Ссылка на техническое описание | обмен ссыками | поиск по производителю All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |