| Electronic Components Datasheet Search |
|
AN4073 Datasheet(PDF) 27 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN4073 Datasheet(HTML) 27 Page - STMicroelectronics |
|
27 / 32 page ![]() DocID022945 Rev 5 27/32 AN4073 Averaging of N-X ADC samples: source code 31 Appendix B Averaging of N-X ADC samples: source code /** * @brief Get the average of N-X ADC samples * @param Numbre of ADC samples to be averaged * @param Numbre of ADC samples to be averaged * @retval The average value */ uint16_t ADC_GetSampleAvgNDeleteX(uint8_t N , uint8_t X) { uint32_t avg_sample =0x00; uint16_t adc_sample[8]={0,0,0,0,0,0,0,0}; uint8_t index=0x00; for (index=0x00; index<N; index++) { /* ADC start conv */ ADC_SoftwareStartConv(ADC1); /* Wait end of conversion */ while(ADC_GetFlagStatus(ADC1,ADC_FLAG_EOC) == RESET); /* Store ADC samples */ adc_sample[index] = ADC_GetConversionValue(ADC1); } /* Sort the N-X ADC samples */ Sort_tab(adc_sample,N); /* Add the N ADC samples */ for (index=X/2; index<N-X/2; index++) { avg_sample += adc_sample[index]; } /* Compute the average of N-X ADC sample */ avg_sample /= N-X; /* Return average value */ return avg_sample; } /** |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List 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 |