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\$
2
  • \$\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\$ Commented Mar 10, 2020 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\$ Commented Mar 10, 2020 at 8:03

3 Answers 3

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.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$
2
  • 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\$ Commented Mar 10, 2020 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\$ Commented Mar 10, 2020 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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.