2020-09-05 02:19 PM
Hello,
I'm developping a software where some timers are totally configured through STM32CubeIDE and others totally configured through registers. I'm getting errors concerning the register configured timers. Here is an example :
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:649:31: error: expected identifier or '(' before 'TIM_TypeDef'
I'm wondering if STM32CubeIDE code and register code is possible! Can someone help me?
Regards,
Solved! Go to Solution.
2020-09-09 12:24 PM
I finally succeeded updating the timer period through TIMx->ARR. The problem was a variable type incompatibility!
2020-09-05 08:39 PM
There's no issue using registers alongside HAL. Technically, the file you're pointing to isn't even HAL, but a CMSIS header.
Your error might be caused by an errant define for one of the timer registers. Did you #define OR somewhere?
2020-09-06 06:43 AM
Thank you for your reply. Well, I haven't defined anything in any file.
I tried different means to overcome the problem but always in the main.c file
First I tried to update the autoreload register with the instruction (from the MX_TIM2_INIT function):
htim3.Init.Period = rand();
and rand() is a function returning an random integer between 800 and 1800, but it didn't work because the autoreload register remained with the first value generated by rand() and didn't consider the following values generated by rand()
After I tried to initialize the timer with CubeIDE but updating the autoreload register with
TIM3->ARR = rand();
The solution seemed to work for a moment (like 30 sec) but then for an unknown reason the autoreload register diverged and contained the value 65536 whereas the rand() function returns values ranging from 800 to 1800. To overcome the problem I enabled the autoreload preload register, but it changed nothing
At last, I tried to totally configure the timer using registers alongside other timers using HAL. And it is at that moment that encountered errors like :
../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:649:31: error: expected identifier or '(' before 'TIM_TypeDef'
I verified and the definition of TIM3 in the stm32f103xb.h is the same as the one in the stm32f10x.h for the register configuration (with Keil for example) :
#define TIM3 ((TIM_TypeDef *)TIM3_BASE);
But I noticed that TIM3_BASE memory map is different in the two files. In stm32f103xb.h, it is
#define TIM3_BASE (APB1PERIPH_BASE + 0x00000400UL);
whereas in stm32f10x.h, it is
#define TIM3_BASE (APB1PERIPH_BASE + 0x0400)
I wonder if those different memory maps may be the problem
Regards,
2020-09-06 07:16 AM
Are you including stm32f10x.h and stm32f103xb.h in the same project? That's not going to work if they both try to define TIM_TypeDef.
2020-09-06 10:07 AM
No, I haven't included both in the same project. There is only the stm32f103xb.h file in my CubeIDE project. I only opened stm32f10x.h using Keil to inspect if the errors were caused by differences of definition of TIM3 in stm32f103xb.h and stm32f10x.h files .
2020-09-06 10:28 AM
2020-09-06 02:24 PM
Well as you said earlier, maybe it is not possible mixing HAL and registers.
Thanks anyway for your help
2020-09-09 12:24 PM
I finally succeeded updating the timer period through TIMx->ARR. The problem was a variable type incompatibility!