-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow provision for user defined TIMx_IRQ_Handlers #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @geosmall |
Hi @geosmall, |
Hi @ABOSTM, |
Hi @geosmall, You are right STM32F0 doesn't support it as it is based on Cortex-M0. |
Apparently doable even on Cortex-M0 using relocation to RAM after carving out enough space for the vectors with modified linker script. It is all a good bit of work and feels a bit work-around. M0 approach here: I thinking user #defines would be a better more versatile approach long term and work across variants. Having to modify linker scripts feels like a non-starter. |
I was able to get NVIC_SetVector() working on STM32F051K6 with the following sketch and linker script. Seems to be working when I insert a breakpoint within the sketch level interrupt routine My_SysTick_IRQHandler(). So this approach could work on F0 targets but would require linker script changes and the use of 256 bytes of RAM for the vector table. Test sketch:
Linker script fro my custom variant:
|
Assuming use of NVIC_SetVector() per above to manage IRQ_Handlers at the sketch level, I run into the next issue. The application I am trying to port originated as an STM32CubeMx project. As such it makes use of HAL_XXX_MspInit() functions. As these functions are claimed within STM32 core I get a series of multiple definition linker errors. The above will make porting of STM32CubeMx generated code or examples to sketches an onerous task. It is possible to work around this by writing local replacement HAL_XXX_Init() functions that then allow one to call their own local HAL_XXX_MspInit() functions, but this is all feels like unnecessary work. I believe that the correct design philosophy is to provide user level build_opt.h switches to turn off TIM / ADC / COMP / Etc... functionality for advanced user applications. Link errors generated:
|
I guess this is the simplest way. Anyway why use Arduino if you generate you code thanks CubeMX why not use directly CubeFw with CubeIDE or other? |
Two reasons, mainly concerned with sharing projects with casual programmer audience:
Explaining CubeMx details to a new-to-STM32 person who's real interest is elsewhere (such as developing drones or robots) kills their interest. Their primary interest is not that of a full time programmer. Eclipse based CubeIDE configuration and management is not for the casual user, way too many options scattered around in obscure places. Most have used Arduino and seem to be able to manage its simple interface. |
Define `HAL_UART_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL UART module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL I2C module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL SPI module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_TIM_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL TIM module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_ADC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL ADC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_DAC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL DAC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL RTC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL PWR module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_UART_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL UART module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL I2C module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL SPI module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_ADC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL ADC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_DAC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL DAC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL RTC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL PWR module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_UART_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL UART module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL I2C module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL SPI module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_TIM_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL TIM module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_ADC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL ADC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_DAC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL DAC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL RTC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL PWR module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_UART_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL UART module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL I2C module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Allow HAL SPI module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_TIM_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL TIM module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_ADC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL ADC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_DAC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL DAC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL RTC module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
Define `HAL_RTC_MODULE_ONLY` in `build_opt.h` or `hal_conf_extra.h` allow HAL PWR module usage without any usage by the core. Fixes stm32duino#697 Signed-off-by: Frederic Pillon <[email protected]>
How do we know what parts of the core this will affect? |
When defining #HAL_TIM_MODULE_ONLY i receive these errors on building:
|
Yes seems logical... |
Sorry, So, all using the HAL module you used. This is for advanced application, so it expects you know what you do and want. About your issue: |
No worries :) I've just used the HardwareTimer library for now instead ;) So should it build if i define both: hal_conf_extra.h
build_opt.h
Like this? I will test it in a moment. |
There is a bug as I mentioned: #839 And again please use the forum. |
Is your feature request/improvement related to a problem? Please describe.
Attempts to make full use of timer features in applications (i.e brushless motor control) require direct access to Timer IRQ Handlers. Current design of HardwareTimer.cpp takes full control of Timer IRQ Handlers. No user level compile switch is available to turn off these features. Any attempts to define sketch level Timer IRQ Handlers generates multiple definition of `TIMx_IRQHandler' errors.
Describe the solution you'd like to see
Provide user level build_opt.h switches to turn off IRQ based HardwareTimer (and associated pin PWM) functionality for advanced user applications.
I've hacked a quick and dirty solution with a user flag in build_opt.h with #ifndef EXCLUDE_HARDWARE_TIMER_MODULE in HardwareTimer.cpp, analog.cpp and wiring_digital.c files to get rid of the multiple definition errors, but have not thoroughly tested yet. I basically replaced #ifdef HAL_TIM_MODULE_ENABLED with my #ifndef so that feature can be turned off while still leaving the HAL_TIM_MODULE enabled. From there I can implement TIMx_IRQ_Handler at the sketch level.
There may be undesirable side effects I am unaware of. I'm guessing there may be a better way.
STM32 Core Design Philosophy Proposal
STM32 peripherals have many powerful features. A design philosophy to be considered for this core would be that features that take over IRQ Handlers (TIM, I2C, etc.) to provide base functionality are on by default but can optionally be switched off by users looking to take full control of the peripheral at the sketch level to gain more advanced functionality. This should also include HAL_XXX_MspInit() functions used to initialize HAL low level hardware initialization (i.e. if MspInit functions are implemented in core library functions then they should also be switchable off by user defines).
The text was updated successfully, but these errors were encountered: