Welcome to MSPM0G3507 Development Board repository
11.MSPM0_K210 handwritten digit recognition
MSPM0_K210 handwritten digit recognition
1. K210 communicates with MSPM0
1.1 Experimental prerequisites
This tutorial uses the MSPM0G3507 development board. K210 needs to run the program in K210-AI(MSPM0G3507) to start the experiment
MSPM0G *1
K210 visual module *1 (must have an SD card (with AI models), camera)
USB to TTL module *1
1.2 Experimental wiring
Method 1: Use USB to TTL module
| MSPM0G | K210 visual module |
|---|---|
| RX | TXD |
| GND | GND |
| VCC | 5V |
| MSPM0G | USB to TTL module |
|---|---|
| TX | RXD |
| GND | GND |

Method 2: Use the onboard Type-C port

1.3 Main code explanation
This example sets the baud rate of the serial port printing to 115200 bps, and the baud rate of the k210 module connection is set to 115200 bps.


xxxxxxxxxxint main(void){ SYSCFG_DL_init(); NVIC_ClearPendingIRQ(MYUART_INST_INT_IRQN);//清除串口中断标志 Clear the serial port interrupt flag NVIC_EnableIRQ(MYUART_INST_INT_IRQN);//是能串口中断 Enable serial port interrupt while (1) { if (k210_msg.class_n != 0)//例程号不为空 Routine number is not empty { if(k210_msg.class_n == 11)//是手写数字识别 Handwritten digit recognition { sprintf(buff_com,"class = %d,x=%d,y=%d,w=%d,h=%d\r\n",k210_msg.class_n,k210_msg.x,k210_msg.y,k210_msg.w,k210_msg.h); uart0_send_string(buff_com); k210_msg.class_n = 0; } } delay_ms(500); }} After the above program, if this routine is run, the members of the k210_msg structure will have corresponding values and will be processed through the serial port printing
k210_msg: is the structure for receiving information, and its main members are
- x: is the horizontal coordinate of the upper left corner of the identified box (range: 0-240)
- y: is the vertical coordinate of the upper left corner of the identified box (range: 0-320)
- w: is the width of the identified box (range: 0-240)
- h: is the length of the identified box (range: 0-320)
- id: is the identified label
- class_n: routine number
- msg_msg[20]: valid data
After the data is received and processed by the function, each member of k210_msg will store valid information. If you want to perform secondary development, you can directly call the members of k210_msg
Note: The keil project source code must be compiled under the SDK path.
1.4 Experimental Phenomenon
- After connecting the cable, the K210 perspective module runs offline. Please check 【6.2 K210 as coprocessor】--【ReadMe】
Link:http://www.yahboom.net/study/K210-Al-Camera
- Set the serial port assistant to the interface shown in the figure
- Then run the handwritten digit recognition routine, and the serial port assistant will print out the important information transmitted by k210 to MSPM0G, as shown in the figure below
Handwritten digit recognition only transmits one member variable of k210_msg, id.
id: refers to the recognized digital ID (0-9)