Welcome to MSPM0G3519 Development Board repository
10. MSPM0_K210 Self-study Classification
MSPM0_K210 Self-learning Classification
1. K210 and MSPM0 Communication
1.1 Experimental Prerequisites
This tutorial uses the MSPM0G3519 development board. K210 needs to run the program in K210-AI(MSPM0) to start the experiment.
MSPM0G3519 *1
K210 vision module *1 (with SD card (with AI model) and camera)
USB to TTL module *1
1.2 Experimental Wiring
Method 1: Using USB to TTL module
| MSPM0G | K210 Vision Module |
|---|---|
| RX | TXD |
| GND | GND |
| VCC | 5V |
| MSPM0G | USB to TTL Module |
|---|---|
| TX | RXD |
| GND | GND |

Method 2: Using onboard Type-C port

1.3 Main Code Explanation
This example sets the serial port print baud rate to 115200 bps, and the K210 module connection baud rate is also set to 115200 bps.


xint main(void){SYSCFG_DL_init();NVIC_ClearPendingIRQ(MYUART_INST_INT_IRQN);//Clear serial port interrupt flagNVIC_EnableIRQ(MYUART_INST_INT_IRQN);//Enable serial port interruptwhile (1){if (k210_msg.class_n != 0)//Example number is not empty{if(k210_msg.class_n == 10)//Self-learning classification{sprintf(buff_com,"id = %c\r\n",k210_msg.id);uart0_send_string(buff_com);k210_msg.class_n = 0;//Clear example number}}delay_ms(500);}}
After the above program runs this example, the k210_msg structure members will have corresponding values and will be printed via serial port.
k210_msg: is the structure for receiving information. Its main members are:
x: is the x-coordinate of the upper-left corner of the recognized box (range: 0-240)
y: is the y-coordinate of the upper-left corner of the recognized box (range: 0-320)
w: is the width of the recognized box (range: 0-240)
h: is the height of the recognized box (range: 0-320)
id: is the recognized label
class_n: example number
msg_msg[20]: valid data
After data reception and processing, each member of k210_msg will store valid information. If you want to do secondary development, you can directly call the members of k210_msg.
Note: The Keil project source code must be placed under the SDK path for compilation.
1.4 Experimental Phenomenon
After connecting the cables, the K210 vision module runs offline. Press key1 on K210 to record object information. Take 15 photos (5 photos for each object), storing 3 objects.
Set the serial assistant interface as shown in the figure

Then run the self-learning classification example. The serial assistant will print the important information transmitted by K210 to MSPM0G, as shown in the figure below.

Object detection only transmits the 1 member variable of k210_msg: id.
id: is the object ID when taking photos. The range of id is (1-3)