How to disable HardwareTimer on STM32 Core?

Post here first, or if you can't find a relevant section!
Post Reply
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

How to disable HardwareTimer on STM32 Core?

Post by feluga »

Hello all!

I need to disable HardwareTimer from using void TIM1_CC_IRQHandler(void)...

Looking into the code of STM32 core, I found a couple possibilities:

1) HardwareTimer.cpp only uses TIM1_CC_IRQHandler() function if TIMER1_BASE is defined... but it sounds impossible to solve because it is defined in stm32f103xb.h (CMSIS). My code needs to use CMSIS...

2) HardwareTimer.cpp has a preprocessing condition in order to be compiled at all:

#if defined(HAL_TIM_MODULE_ENABLED) && !defined(HAL_TIM_MODULE_ONLY)

- HAL_TIM_MODULE_ENABLED is already defined in HAL settings (stm32f0xx_hal_conf_default.h)
- HAL_TIM_MODULE_ONLY seems to be the way to do it! It is tested in preprocessing of several Arduino parts, but never defined.

Thus one way to disable HardwareTimer.cpp compilation and to be able to create my own TIM1_CC_IRQHandler() would be to force Arduino compiler script to add a -DHAL_TIM_MODULE_ONLY in compile time.

Questions:
1) Is it the only way to allow me to cretate my own TIM1_CC_IRQHandler()?
2) If so, how can I set such -DHAL_TIM_MODULE_ONLY in compile time in a very transparent way to user?
3) What other way could I create, compile and link my own TIM1_CC_IRQHandler()?

Thanks in advance!
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: How to disable HardwareTimer on STM32 Core?

Post by feluga »

thanks for your help!
I added build_opt.h file to my scketch as below:

Code: Select all

-DHAL_TIM_MODULE_ONLY
I tested it in the blink.ino sketch, as below.

Code: Select all


// preprocessor testing for build_opt.h
#ifdef HAL_TIM_MODULE_ONLY
#warning "HAL_TIM_MODELU_ONLY is DEFINED, OK!"
#endif

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level):
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
but it sounds like there are some issues in the 1.8.0 version for STM32Core using STM32F103 generic board...

Code: Select all

Compiling sketch...
"C:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\tools\xpack-arm-none-eabi-gcc\9.2.1-1.1/bin/arm-none-eabi-g++" -mcpu=cortex-m3  -mthumb "@C:\Users\rodrigo\AppData\Local\Temp\arduino_build_294009/sketch/build_opt.h" -c -Os  -std=gnu++14 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -fno-use-cxa-atexit -MMD "-IC:\Users\rodrigo\Documents\Arduino\proj_rodrigo\Blink_noHardwareTimer" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/avr" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/LL" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/usb" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/usb/hid" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/usb/cdc" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Drivers/STM32F1xx_HAL_Driver/Inc" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Drivers/STM32F1xx_HAL_Driver/Src" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/STM32F1xx" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Middlewares/ST/STM32_USB_Device_Library/Core/Src" -DSTM32F1xx -DARDUINO=10805 -DARDUINO_BLUEPILL_F103C8 -DARDUINO_ARCH_STM32 -DBOARD_NAME="BLUEPILL_F103C8"  -DSTM32F103xB    "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/Core/Include/" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\system/Drivers/CMSIS/Device/ST/STM32F1xx/Source/Templates/gcc/" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\tools\CMSIS\5.5.1/CMSIS/DSP/Include" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\variants\PILL_F103XX" "-IC:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src" "C:\Users\rodrigo\AppData\Local\Temp\arduino_build_294009\sketch\Blink_noHardwareTimer.ino.cpp" -o "C:\Users\rodrigo\AppData\Local\Temp\arduino_build_294009\sketch\Blink_noHardwareTimer.ino.cpp.o"
C:\Users\rodrigo\Documents\Arduino\proj_rodrigo\Blink_noHardwareTimer\Blink_noHardwareTimer.ino:26:2: warning: #warning "HAL_TIM_MODELU_ONLY is DEFINED, OK!" [-Wcpp]
   26 | #warning "HAL_TIM_MODELU_ONLY is DEFINED, OK!"
      |  ^~~~~~~
In file included from C:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/board.h:8,
                 from C:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/wiring.h:41,
                 from C:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/Arduino.h:32,
                 from C:\Users\rodrigo\AppData\Local\Temp\arduino_build_294009\sketch\Blink_noHardwareTimer.ino.cpp:1:
C:\Users\rodrigo\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/analog.h:55:66: error: 'TimerCompareFormat_t' has not been declared
   55 | void pwm_start(PinName pin, uint32_t clock_freq, uint32_t value, TimerCompareFormat_t resolution);
      |  


Is it a bug on the STM32 Core version 1.8.0?
Or am I doing something wrong?
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: How to disable HardwareTimer on STM32 Core?

Post by feluga »

feluga wrote: Fri May 15, 2020 1:53 am Is it a bug on the STM32 Core version 1.8.0?
Or am I doing something wrong?
I checked it on GitHub and it sounds like this issue with analog.h has been fixed in the version 1.9.0
But this version is not available to be installed by Arduino IDE Board Manager...

I managed to fix it manually, but I'll wait version 1.9.0 to be realeased in order to publish a library...
User avatar
fpiSTM
Posts: 1745
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: How to disable HardwareTimer on STM32 Core?

Post by fpiSTM »

Yes it is fixed in the master and will be available in the next release 1.9.0, which will be release in the coming days.
feluga
Posts: 64
Joined: Wed Mar 18, 2020 2:50 am

Re: How to disable HardwareTimer on STM32 Core?

Post by feluga »

fpiSTM wrote: Fri May 15, 2020 4:41 am Yes it is fixed in the master and will be available in the next release 1.9.0, which will be release in the coming days.
I just noticed that version 1.9.0 is released.

I just updated my library BlueVGA to verion 1.0 that works transparently for both cores (STM32 and Roger's).
The library and source code can be found in https://github.com/RoCorbera/BlueVGA

Thanks!
Post Reply

Return to “General discussion”