2019-12-17 05:39 PM
I using STM32F103C8, SW4STM32 and CubeMx
When using input capture mode and call
__HAL_TIM_SET_CAPTUREPOLARITY(htim, TIM_CHANNEL_1, TIM_INPUTCHANNELPOLARITY_FALLING);
The complier always show error:
/Users/duonghuuhoang/iWorks/ARM/TIM_InputCapture/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h:1745:106: error: expected ':' before ')' token
I do not modify and any single line in stm32f1xx_hal_tim.h
Solved! Go to Solution.
2019-12-20 03:20 AM
So the problem is clear: the brackets are not balanced, line 2 should be
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
(i.e. one of the closing brackes at the end removed)
Appears to be a CubeF1 bug then.
@Amel NASRI , can you please have a look at it?
Thanks,
JW
2019-12-18 12:43 AM
And what is on and around line 1745 in stm32f1xx_hal_tim.h?
If you'll see nothing suspicious there, you should trace all macros defied there up to their origin. One way to approach this is to generate the preprocessed source, using -E instead of -c in the gcc command line - I don't use SW4STM32 so I don't know how to do that there.
I don't use Cube/CubeMX.
JW
2019-12-20 12:37 AM
#define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) \
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP))) :\
((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) :\
((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P)) :\
((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P)))
that is the code of ST Lib from stm32f1xx_hal_tim.h
i try using __HAL_TIM_SET_CAPTUREPOLARITY() function but using stm32f4 family , it working fine without error
and my output when using preprocessed (-E) :
Building target: TIM_InputCapture.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -T"../STM32F103C8Tx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -o "TIM_InputCapture.elf" @"objects.list" -lm
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [TIM_InputCapture.elf] Error 1
@Community member thanks for answer
2019-12-20 03:20 AM
So the problem is clear: the brackets are not balanced, line 2 should be
(((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP)) :\
(i.e. one of the closing brackes at the end removed)
Appears to be a CubeF1 bug then.
@Amel NASRI , can you please have a look at it?
Thanks,
JW
2019-12-20 05:25 PM
@Community member Thanks so much , i remove brackes at the end of line 2 and now it work normal.
2019-12-31 01:39 AM
Thanks @Community member for bringing this error to our attention.
It is tracked internally (ref78456).
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2019-12-31 02:24 AM
Thanks, Amel.
Jan
2020-03-02 03:47 PM