From 839c22c74e2efd8c1b69e6344729c820dba01391 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sun, 29 May 2016 03:13:16 +0200 Subject: [PATCH] ADC trig dir set by adc trig edge, CC irq dir set by Center aligned mode 1,2,3 --- Src/test.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Src/test.c b/Src/test.c index 0cc982bc..b35011cb 100644 --- a/Src/test.c +++ b/Src/test.c @@ -2,6 +2,7 @@ #include "test.h" #include "cmsis_os.h" +#include "stm32f405xx.h" #include "stm32f4xx.h" #include "stm32f4xx_hal_adc.h" #include "stm32f4xx_hal_adc_ex.h" @@ -12,11 +13,15 @@ static void test_read_ADC(void); +static int test_base = 0; static int test = 0; static int test2 = 0; void test_main(void) { + //Set trigger to mid phase to check for trigger polarity + htim1.Instance->CCR4 = 2048; + HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_4); __HAL_ADC_ENABLE(&hadc2); @@ -45,13 +50,19 @@ void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) { assert(hadc == &hadc2); float unknown_ch_volts = read_ADC_volts(hadc, 1); - test++; + uint32_t cnt = htim1.Instance->CNT; + int dir = htim1.Instance->CR1 & TIM_CR1_DIR; + if(dir){ + test++; + } else { + test2++; + } } void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) { //We only expect the timing driving channel to trigger an interrupt. assert(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4); - test2++; + test_base++; }