2014-05-13 01:53 PM
hello All,
i want to start an ADC with DMA in a timer(5) interrupt routine. when i test timer and adc individually they work right. but when i insert ADC start, in timer isr the timer and adc works once and then timer stays in the isr and adc does not start again. can anyone help me please? my code is looks like below. Thanks
void
TIM5_IRQHandler(
void
)
//Start ADC after delay
{
HAL_NVIC_ClearPendingIRQ(TIM5_IRQn);
HAL_TIM_IRQHandler(&htim5);
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_10);
HAL_ADC_Start_DMA((&hadc1) ,(uint32_t*)&uhADCxConvertedValue, 1000);
}
void
HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_11);
HAL_ADC_Stop_DMA(&hadc1);
}
2014-05-13 09:40 PM
I found that when DMA sample length set under 540 instead of 1000, it works!
but the timer period is about 1ms and adc conversion take about 700us for 1000 samples and 400us for 540 samples. i really confused! does anyone have any idea ?2014-05-14 11:52 PM
still no one has any idea!
i found that when i start a timer and adc+dma only adc works and timer stay in interrupt routine. in main function i just add this:__IO uint16_t data[1000];
int
main(
void
)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_TIM5_Init();
HAL_TIMEx_OCN_Start_IT(&htim5,TIM_CHANNEL_1);
HAL_ADC_Start_DMA(&hadc1,(uint32_t*)&data,700);
...
and adc works but timer stays in interrupt. why?!!! if i don't start adc the timer works normally.
please help me
2014-05-15 06:29 AM
still no one has any idea!
I think it's more the forum expressing disinterest with Cube and/or random fragments of code.2014-05-15 12:42 PM
thanks clive1, your right!
my problem was not from cube, i have some problems with keil, im new to it.i found that when i declare ''TIM_HandleTypeDef htim5'' in tim.c and extern in time.h and declare in main.c as ''extern TIM_HandleTypeDef htim5'' the timer doesn't work. but vise versa if i declare it in main.c and use it in tim.c , code works normal. i still don't understand why.