2018-01-29 12:30 AM
Hi. I have a very strange behaviour with adc.
The CubeMX setup is shown belowThis is my empty callback
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
}And the main
int main(void)
{ HAL_Init();SystemClock_Config();
MX_GPIO_Init();
MX_ADC_Init();HAL_ADC_Start_IT(&hadc);
while (1)
{ HAL_GPIO_WritePin(Led0_GPIO_Port, Led0_Pin, GPIO_PIN_SET); HAL_Delay(100); HAL_GPIO_WritePin(Led0_GPIO_Port, Led0_Pin, GPIO_PIN_RESET); HAL_Delay(100); }}
The program does not work. In order to have my led blinking it working I have to comment out the line
HAL_ADC_Start_IT(&hadc);
What is wrong?
2018-01-29 01:34 AM
on my '091 solution I am using cube 4.22.1, not using the A/D/Interrupt, but DMA,
I use this:
#define ADC_ChannelCount; 12;
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
if(!ADC_ChannelsCounter--) { // after all the channels have been refilled
ADC_ChannelsCounter = ADC_ChannelCount;
HAL_ADC_CompleteCycle = true; // signal foreground to process
// copy 15 results away nowADC_Channel_Buffer[i] = ADC_DMABuffer[i];
}}2018-01-29 03:42 AM
Many thanks for your fast reply.
Now I have switched my project to dma but I have a problem.hadc.Init.ContinuousConvMode = ENABLE;seems to be not considered because the variable will updated only one time.2018-01-29 04:03 PM
I have this config:
________________ Attachments : ADC setup.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hy5L&d=%2Fa%2F0X0000000b3o%2Fa7Kl92Re6e_ws6plk1RoQdCkcgVxoKKzc9XNMWKsjSA&asPdf=false