|
@@ -49,7 +49,7 @@ void Board_Init(void)
|
|
|
//GPIO_SetPinSpeed(GPIOA, GPIO_PIN_8, GPIO_OSPEED_VH);
|
|
|
//GPIO_SetPinPull(GPIOA, GPIO_PIN_8, GPIO_PUPDR_NO);
|
|
|
|
|
|
- //ADC_Init();
|
|
|
+ ADC_Init();
|
|
|
|
|
|
TIM1_Init();
|
|
|
TIM3_Init();
|
|
@@ -134,7 +134,8 @@ static void ADC_Init(void)
|
|
|
ADC1->ISR |= ADC_ISR_CCRDY;
|
|
|
|
|
|
/* External trigger - Tim3 */
|
|
|
- ADC1->CFGR1 |= (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_CFGR1_EXTEN_0 | ADC_CFGR1_OVRMOD);
|
|
|
+ //ADC1->CFGR1 |= (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0 | ADC_CFGR1_EXTEN_0 | ADC_CFGR1_OVRMOD);
|
|
|
+ ADC1->CFGR1 = ADC_CFGR1_OVRMOD;
|
|
|
|
|
|
/* Enable ADC internal voltage regulator */
|
|
|
ADC1->CR |= ADC_CR_ADVREGEN; // ???
|
|
@@ -169,6 +170,9 @@ static void ADC_Init(void)
|
|
|
*/
|
|
|
static void TIM1_Init(void)
|
|
|
{
|
|
|
+ /* TIM1 interrupt Init */
|
|
|
+ NVIC_SetPriority(TIM1_BRK_UP_TRG_COM_IRQn, 0);
|
|
|
+ NVIC_EnableIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
|
|
|
/* target clock */
|
|
|
TIM1->PSC = TIM1_PSC; // prescaler
|
|
|
TIM1->ARR = TIM1_ARR; // auto reload value
|
|
@@ -184,6 +188,8 @@ static void TIM1_Init(void)
|
|
|
TIM1->EGR = TIM_EGR_UG; // force timer update
|
|
|
/* TIM1 CC_EnableChannel */
|
|
|
TIM1->CCER = (TIM_CCER_CC1E | TIM_CCER_CC1P | TIM_CCER_CC4E | TIM_CCER_CC4P);
|
|
|
+ /* Enable interrupts */
|
|
|
+ TIM1->DIER = TIM_DIER_UIE;
|
|
|
/* TIM_EnableCounter */
|
|
|
TIM1->CR1 |= TIM_CR1_CEN;
|
|
|
}
|
|
@@ -198,7 +204,7 @@ static void TIM3_Init(void)
|
|
|
/* target clock */
|
|
|
TIM3->PSC = TIM3_PSC; // prescaler
|
|
|
TIM3->ARR = TIM3_ARR; // auto reload value
|
|
|
- TIM3->CR1 = TIM_CR1_ARPE;
|
|
|
+ TIM3->CR1 = TIM_CR1_ARPE | TIM_CR1_DIR;
|
|
|
// launch timer
|
|
|
TIM3->EGR = TIM_EGR_UG; // force timer update
|
|
|
/* Set the trigger output 2 (TRGO2) used for ADC synchronization */
|