2017-10-30 08:19 AM
Hi,
This discussion is more like a bug report than a help request. Therefore it would be nice, if these bugs could be confirmed and fixed;These bugs appears, when I use ADC 'dual regular simultaneous mode', using DMA transfers (created using as reference AN3116). Used MCU = STM32F103VET6; Code generated using STM32CubeMX, v.4.18.0. Used libraries: STM32Cube FW F1 V1.6.0.
I scan 5 channels for ADC1 and 5 channels for ADC2.
As result, when I Build and run auto-generated code, adding just few lines:
HAL_ADCEx_Calibration_Start(&hadc1);
HAL_ADCEx_Calibration_Start(&hadc2);HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t*)dmaAdcBuff, DMA_ADC1_BUFF_SIZE);
, the first bug appeared:
1) inside MX_ADC2_Init(); function there is expression:multimode.Mode = ADC_DUALMODE_REGSIMULT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc2, &multimode) != HAL_OK){Error_Handler();}which always leads to Error_Handler(); for ADC2
My Solution for bug #1 was just deleting this piece of code;
2) Later, when I managed to make my code run continously, second bug appears (
don't know, if it's
dependent on
my 'fix' above, whether it's independent). This bug is that function
HAL_ADCEx_MultiModeStart_DMA(&hadc1,(uint32_t*)dmaAdcBuff, DMA_ADC1_BUFF_SIZE);
returns with no result (I mean, it does not do, what it should, because it returns with Error)
My solution for bug #2 was adding following lines of code:
hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
if (HAL_ADC_Init(&hadc2) != HAL_OK) { Error_Handler(); }before HAL_ADCEx_MultiModeStart_DMA(...); function (IMHO its epic fail that CubeMX haven't generated hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START; line)
3) Later, when I managed to launch DMA transfers, and see that buffer updates, third bug appears: looks like ADC2 is not working: all channels of ADC1 ar filled correctly; ADC2 all channels have same value.
My solution for bug #3 was: add code piece :
hadc2.Instance->CR2 |= ADC_CR2_EXTTRIG;
before HAL_ADCEx_MultiModeStart_DMA(...); function
Conclusions:
CubeMX and HAL libraries make life easier, but in specific modes it can bring lots of trouble and misunderstanding, if there is no appropriate code examples...(I was porting my project from StdPeripheral Library to HAL, and there were no problems in old lib =). moreover, actually, old lib with its examples helped me a lot to find the third bug. )2017-10-30 09:20 AM
Hello,
I cannot reproduce the first bug with CubeMx 4.23 ! Could you please check if these bugs are reproduced with the last version of CubeMx 4.23?
Please share your .ioc file, it will be very helpful to check the reported issues.
Best Regards
Imen
2017-10-31 02:44 AM
Hi Imen,
I've installed new version of CubeMx; as result, bugs #1 and #2 disappeared
The bug #3 still requires linehadc2.Instance->CR2 |= ADC_CR2_EXTTRIG; so that ADC2 also fill buffer with DR values.
However, one more issue: new bug appeared in other place, where timer intiailizes:
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
and compiler says 'Field 'AutoReloadPreload' could not be resolved tim.c /BatteryTester_CUBE_HAL/Src line 62 Semantic Error' version ofstm32f1xx_hal_tim.h file (generated by CubeMX) is v1.0.4 ;I checked whether it's lastest version, and looks like no. (lastest is v1.1.1)if I delete this line, code works fine..
please, see .ioc file in attachment ________________ Attachments : ADC_DualRegSimult_5plus5.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyLE&d=%2Fa%2F0X0000000b6H%2FKrYhMZnfvAGrycJKYEGx_kYnElmipruT9dyjQUPSyLg&asPdf=false2018-02-13 12:58 AM
Hello
V.Jurijs
,I checked your ioc file, I can reproduce the issue you highlighted.
However, I see that you are working onSTM32Cube FW_F1 V1.4.0, and in FW_F1 V1.6.0, the issue is not present as TIM_AUTORELOAD_PRELOAD_ENABLE is defined :
Please, use FW_F1 V1.6.0.
BR. Jeanne