
Inverter Kit Programming
This section explains how to program the inverter kit, which is common to all CQ brushless motor production kits. (To view the source code, you will need the documentation included with the kit.)
Kits covered by this section
●Brushless Motor & Inverter Kit 2H High Grade Set ●Brushless Motor & Inverter Kit 2H Economy Set
- CQ Brushless Motor Production Kit Parts Set 1
●Inverter 2 (high grade)
●Inverter 2 (Economy)
1. Preparing the development environment
Please register an account for arm Keil Studio using the link below. On the login screen, there are radio buttons for "Classic" and "CMSIS", but leave it at "Classic".
(Support for the Mbed Online Compiler will end in December 2022. The Arm Keil Studio Cloud used here is its successor software. If you have an Mbed Online Compiler account, you can continue to use it.)

2. Download the source code
Please download the inverter kit source code from the link below.
(For the password, refer to page 2 of "Inverter Kit 2 - Square Wave Software Edition.")

3. Creating and building a project
●Create a new project
Once you have logged in to keil Studio, set up a new project by clicking "+New project".
In the "Example Project" field, select "mbed2-example-blinky" and enter an appropriate project name.
Finally, click the "Add project" button to create the project.
(No need to change the checkboxes)

●Selecting the target board
From the "Build target" column
As a target board
"NUCLEO-F302R8"
Select

● Paste source code
Double-click the project's main.cpp to open it and delete the source code that is included by default.
Extract the zip file obtained in "2. Download the source code" and open the main.cpp file contained within in a text editor such as Notepad.
Copy the code inside and paste it where the default Keil Studio code was.
(You cannot select Paste using the mouse, so press Ctrl + V on the keyboard to paste.)

●Rewrite mbed.bld
As with main.cpp, double-click mbed.bld in the project to open it.
The contents of the end of the file (only after the last /)
176b8275d35d
from
65be27845400
Rewrite it to:

The final mbed.bld content is as follows:
https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
●Building the source code
Click the hammer icon to build the source code.
A window will open asking you to specify the download destination folder, so specify the save location.
The built firmware will now be saved on your PC.

4. Microcontroller board power settings
The STM32F302R8 (STMicroelectronics), the microcontroller board included in the Brushless Motor & Inverter Kit 2, has several jumper pins. Among these, pin JP5 is used to select the power supply.
① When powering via USB
If you connect the jumper on pin JP5 to the U5V side , you will be able to supply power from USB (USB mini).
②When using an external power supply
If you are using an external power supply such as a battery, connect the jumper on pin JP5 to the E5V side .
In this explanation, we will write source code, so we will use USB power supply (1).

5. Writing the program
To write, simply connect the PC and microcontroller board and perform drag and drop.
When you connect the microcontroller board to your PC using a USB cable, the microcontroller board will be recognized as a new drive.
Drag and drop the file (.bin) downloaded in "3. Creating and building the project" into this drive.
(The dragged and dropped file will become invisible once writing is complete.)
Make sure that the LED (LD1) on the microcontroller board turns green, then remove it from the PC.
If that doesn't work, please check this as well.

