0
\$\begingroup\$

I'm trying to use a __set_BASEPRI() function in Keil to set up interrupts in STM32F407 but it doesn't work when I compile the code and the IDE shows warning "implicit declaration of function '__set_BASEPRI' is invalid in C99". Functions __enable_irq() and __disable_irq() work fine. How do I make it work?

Also weird, when I click on "Go to definition" on all these functions, the IDE cannot find the source file for them even though cmsis_armcc.h is included in the project.

\$\endgroup\$
  • \$\begingroup\$ Do a text file search for "__set_BASEPRI" in all the .h file you have at disposal. Probably you will gather some info. \$\endgroup\$ – linuxfan says Reinstate Monica Mar 10 at 7:16
  • \$\begingroup\$ @linuxfansaysReinstateMonica its included in cmsis_armcc.h, cmsis_armclang.h and cmsis_gcc.h. The former is included in my project. \$\endgroup\$ – Archimedes Mar 10 at 8:03
1
\$\begingroup\$

__get_BASEPRI() is defined in cmsis_armcc.h, but only if __TARGET_ARCH_7E_M (ARMv7-M, Cortex-M3) or __TARGET_ARCH_7E_M (ARMv7E-M, Cortex-M4, M7) is defined. The BASEPRI special register is not supported in ARMv6-M, Cortex-M0, M0+, and M1. Make sure you have the correct device selected in the Options for Target dialog.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

That usually happens when the prototype is not included. Have you included the relevant .h file?

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Keil includes cmsis_armcc.h automatically. Including it manually doesn't fix the problem. I also tried a fresh Keil install on another PC and everything works fine, so this is probably an IDE problem, not my code. Reinstalling Keil on my PC didn't help. \$\endgroup\$ – Archimedes Mar 10 at 8:04
  • \$\begingroup\$ @Archimedes If a re-install did not fix it on your machine but did on another, that suggests something is "left behind" in the registry \$\endgroup\$ – Dirk Bruere Mar 10 at 15:35
0
\$\begingroup\$

The problem lied in a compiler I was using. By default Keil uses ARMCC (default compiler 5). When I switched to ARMCLANG (default compiler 6), the problem resolved.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.