Skip to content

TIM1_IRQn wrong definition for STM32F410x #878

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

Closed
MCUdude opened this issue Jan 20, 2020 · 7 comments · Fixed by #882
Closed

TIM1_IRQn wrong definition for STM32F410x #878

MCUdude opened this issue Jan 20, 2020 · 7 comments · Fixed by #882
Assignees
Labels
bug 🐛 Something isn't working
Milestone

Comments

@MCUdude
Copy link
Contributor

MCUdude commented Jan 20, 2020

Hi!
I'm playing around with my Nucleo F410RE board to see if I can get it working with this core.
I've created a generic pinout for it (that I haven't pushed yet), but I'm not able to compile code for it due to a bug (?) in the core system files.

This is the error I get whenever I compile something:

In file included from C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c:14:
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c: In function 'getTimerUpIrq':
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/timer.h:54:19: error: 'TIM1_UP_TIM10_IRQn' undeclared (first use in this function); did you mean 'TIM1_BRK_TIM9_IRQn'?
   54 | #define TIM1_IRQn TIM1_UP_TIM10_IRQn
      |                   ^~~~~~~~~~~~~~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c:374:16: note: in expansion of macro 'TIM1_IRQn'
  374 |         IRQn = TIM1_IRQn;
      |                ^~~~~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\cores\arduino/stm32/timer.h:54:19: note: each undeclared identifier is reported only once for each function it appears in
   54 | #define TIM1_IRQn TIM1_UP_TIM10_IRQn
      |                   ^~~~~~~~~~~~~~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c:374:16: note: in expansion of macro 'TIM1_IRQn'
  374 |         IRQn = TIM1_IRQn;
      |                ^~~~~~~~~

However: if I change this line in stm32f410rx.h to TIM1_UP_TIM10_IRQn it does compile without any errors:

TIM1_UP_IRQn = 25, /*!< TIM1 Update Interrupt */

Any reason why TIM1_UP_TIM10_IRQn isn't defined for any of the F410 targets?

@fpistm
Copy link
Member

fpistm commented Jan 20, 2020

Hi @MCUdude
In fact to simplify IRQ handling, Each IRQn is mapped on a generic name TIMx_IRQn.
So for this F410 it seems not needed to map it as it already exist.
They are some exception already present.

The fix have to be made here:

#define TIM1_IRQn TIM1_UP_TIM10_IRQn
#define TIM1_IRQHandler TIM1_UP_TIM10_IRQHandler

#elif defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
+ #if defined(TIM10_BASE) && !defined(TIM10 _IRQn)
#define TIM1_IRQn TIM1_UP_TIM10_IRQn
#define TIM1_IRQHandler TIM1_UP_TIM10_IRQHandler
+ #else
+ #define TIM1_IRQn TIM1_UP_IRQn
+ #define TIM1_IRQHandler TIM1_UP_IRQHandler
+ #endif

@MCUdude
Copy link
Contributor Author

MCUdude commented Jan 20, 2020

Great. Is this something I can add together with a "Generic F410Rx pinout" PR?

@fpistm
Copy link
Member

fpistm commented Jan 20, 2020

Well, first it need to be tested 😉

@MCUdude
Copy link
Contributor Author

MCUdude commented Jan 20, 2020

Well, sadly it didn't solve the problem 😢

Snippet from timer.h

#elif defined(STM32F3xx) || defined(STM32L4xx) || defined(STM32WBxx)
#define TIM1_IRQn TIM1_UP_TIM16_IRQn
#define TIM1_IRQHandler TIM1_UP_TIM16_IRQHandler
#elif defined(STM32F2xx) || defined(STM32F4xx) || defined(STM32F7xx)
#if defined(TIM10_BASE) && !defined(TIM10_IRQn)
#define TIM1_IRQn TIM1_UP_TIM10_IRQn
#define TIM1_IRQHandler TIM1_UP_TIM10_IRQHandler
#endif
#elif defined(STM32H7xx) || defined(STM32MP1xx)
#define TIM1_IRQn TIM1_UP_IRQn
#define TIM1_IRQHandler TIM1_UP_IRQHandler
#endif
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c: In function 'getTimerUpIrq':
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c:374:16: error: 'TIM1_IRQn' undeclared (first use in this function); did you mean 'TIM5_IRQn'?
  374 |         IRQn = TIM1_IRQn;
      |                ^~~~~~~~~
      |                TIM5_IRQn
C:\Users\user\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\libraries\SrcWrapper\src\stm32\timer.c:374:16: note: each undeclared identifier is reported only once for each function it appears in

@fpistm
Copy link
Member

fpistm commented Jan 20, 2020

Right I didn't saw the UP. I've corrected.
Anyway I will have to check if this could be set in the next preprocess as it defines it properly for TIM1_UP.
#elif defined(STM32H7xx) || defined(STM32MP1xx)

@MCUdude
Copy link
Contributor Author

MCUdude commented Jan 20, 2020

@fpistm do you want me to create a PR for the Generic F410Rx variant I'm working on (pretty much done with)? This would probably make it a little easier for you to track this issue down 🙂

@fpistm
Copy link
Member

fpistm commented Jan 21, 2020

Yes, thanks @MCUdude

@fpistm fpistm changed the title Weird compile error for STM32F410Rx TIM1_IRQn wrong definition for STM32F410x Jan 21, 2020
@fpistm fpistm added the bug 🐛 Something isn't working label Jan 21, 2020
@fpistm fpistm self-assigned this Jan 21, 2020
@fpistm fpistm added this to the 1.9.0 milestone Jan 21, 2020
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Jan 21, 2020
fpistm added a commit that referenced this issue Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants