cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 ADC1 starting conversion from TIM1 CC4 event - doesn't work

flauwear
Associate
Posted on September 23, 2012 at 12:34

Hello. I colided with the following problem: ADC1 doesn't start conversion in injected channel from TIM1 CC4 event. Below I quote a piece of code of my initialization of ADC1 and TIM1:

RCC->APB2ENR|=RCC_APB2ENR_TIM1EN;  //TIM1 clocking enable

TIM1->PSC=83;                      //Prescaler 84 (83 + 1) (168 MHz/84=2 MHz)

TIM1->ARR=0xFFFF;                  //ARR value 

TIM1->CCER|=TIM_CCER_CC4E;    //Capture enable 4

TIM1->CCR4=10000;                  //CCR4 value

TIM1->CR1|=TIM_CR1_CEN;          //Counting enable

//****************************************************************

//*ADC1

//****************************************************************

void ADC_Config(void){

//------------------------------------------------------------------------------

//*GPIOA analog function

//------------------------------------------------------------------------------ 

RCC->AHB1ENR|=RCC_AHB1ENR_GPIOAEN; //PORTA clocking on

GPIOA->MODER|=GPIO_MODER_MODER1;   //PA1 analog function

//------------------------------------------------------------------------------

//*ADC1 initialization

//-----------------------------------------------------------------------------  

RCC->APB2ENR|=RCC_APB2ENR_ADC1EN; //ADC1 clocking on

ADC1->SMPR2|=ADC_SMPR2_SMP1_0

    |ADC_SMPR2_SMP1_1

    |ADC_SMPR2_SMP1_2;            //Conversion cycle

ADC1->JSQR|=ADC_JSQR_JSQ4_0;      //Conversion in which channel

//-------------------------------------------------------------------------------

ADC1->CR2&=~ADC_CR2_JEXTSEL;      //External event - TIM1_CH4

ADC1->CR2|=ADC_CR2_JEXTEN_0;      //Trigger detection on the rising edge

//-------------------------------------------------------------------------------

ADC1->CR2|=ADC_CR2_ADON;          //ADC1 ON

//ADC1->CR2|=ADC_CR2_JSWSTART;    //Starting conversion of injected channel

result=ADC1->JDR1;                //Result

}

I can't understand what and where I missed.
1 REPLY 1
dhvinay
Associate
Posted on June 11, 2014 at 15:30

Were you able to debug it successfully? If so, could you update the same?

Thanks in advance.