|
@@ -42,7 +42,8 @@
|
|
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
/* USER CODE BEGIN PV */
|
|
|
-extern uint32_t adcCounter;
|
|
|
+uint32_t adcCounter=0;
|
|
|
+uint16_t maxWaveDiff = 0; // Stores the latest measured ADC Wave data (MAX-MIN)
|
|
|
|
|
|
/* USER CODE END PV */
|
|
|
|
|
@@ -207,11 +208,38 @@ void SysTick_Handler(void)
|
|
|
void ADC1_2_IRQHandler(void)
|
|
|
{
|
|
|
/* USER CODE BEGIN ADC1_2_IRQn 0 */
|
|
|
- volatile static uint16_t adcData = 0;
|
|
|
|
|
|
- //__HAL_ADC_CLEAR_FLAG(&hadc1,ADC_FLAG_EOC);
|
|
|
+ /**
|
|
|
+ * Test with osc wave out 50Hz Sine 2160mV (according to Osc measurement)
|
|
|
+ *
|
|
|
+ * ADC is 0-3.3V on 12 bits = 4096 bits = 0,8056640625mV / bit
|
|
|
+ *
|
|
|
+ * max-min measured in ADC of 2605 = 2098,7mV so a small diff of 61mV
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+ static uint16_t adcData = 0;
|
|
|
+ static uint16_t minValue = 0xFFF;
|
|
|
+ static uint16_t maxValue = 0;
|
|
|
+
|
|
|
+ static uint32_t cnt = 10000; // 205 882,35Hz = 4 117,6 samples/wave. 10000 samples = 48mS = 2.4 Waves
|
|
|
+
|
|
|
adcData = ADC1->DR;
|
|
|
- adcCounter++;
|
|
|
+
|
|
|
+ if( cnt > 0 ) {
|
|
|
+ if( adcData > maxValue ) maxValue = adcData;
|
|
|
+ else if( adcData < minValue ) minValue = adcData;
|
|
|
+ cnt--;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ cnt = 10000;
|
|
|
+ maxWaveDiff = maxValue - minValue;
|
|
|
+ maxValue = minValue = 0;
|
|
|
+ adcCounter++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/* USER CODE END ADC1_2_IRQn 0 */
|
|
|
/* USER CODE BEGIN ADC1_2_IRQn 1 */
|