The latest version of 2023~KEIL5 uses C++ to develop STM32

Look at the effect firstInsert image description here

Start teaching


Since this is my first time writing this configuration tutorial, I will try to be as detailed as possible.

Open a Keil project

Insert image description here

Remove local core Add online core


Insert image description here
Insert image description here

There will be no errors when compiling the code for the first time.

Insert image description here


Modify main.c file type to C++


Insert image description here
Insert image description here


Click the magic wand to change the ARM compiler to V6


Insert image description here

The second compilation will report an error syntax incompatibility.


I shielded these codes in the assembly part (no need for lazy ovo)


Insert image description here


Added redirect code


Insert image description here


After the modification, the error was resolved after compiling for the third time.


Insert image description here


Link C functions (C++ cannot call C functions directly)


Insert image description here


Write a test code and send it to the serial port assistant for viewing


Insert image description here

C++ syntax test class


Insert image description here

Configure printf output


Insert image description here

Insert image description here


Use cout output


Insert image description here

expand


If you use cout, it will not be too good for the memory of the microcontroller. Compile the two codes and see the memory size.


Insert image description here

Insert image description here

Data acquisition


Click below~

Guess you like

Origin blog.csdn.net/lllmeimei/article/details/132380399