K210 Vision Module

K210 Vision Module2.1 Serial Communication2.2 k210 Vision Module2.3 Hardware Connection2.4 Environment Setup2.5 Partial Code Explanation2.6 Main Functions2.7 K210 Program Burning2.8 Experimental Phenomenon

2.1 Serial Communication

USART: Universal Synchronous/Asynchronous Receiver/Transmitter. It can automatically generate data frame timing based on one byte of data from the data register and send it out through the TX pin, or automatically receive data frame timing from the RX pin and concatenate it into one byte of data, stored in the data register. This experiment uses UART2.

image-20230926100744845

When using serial port for communication, both communication parties must be on the "same channel". "Same channel" means the same communication protocol. Serial port (USART) stipulates: data must be transmitted in the form of "frames" during communication. One frame of serial port data includes: start bit + data bit + parity bit + stop bit. Where: 1) Start bit: fixed is 1 cycle low level signal 2) Data bit: can be agreed by both parties as 5 ~ 9 bits 3) Parity bit: serial port uses parity check, can be agreed by both parties 4) Stop bit: optional 0.5 ~ 2 cycles high level. At the same time, to synchronize the transmission speed of both parties, it is also necessary to agree on the number of data frames transmitted per second, called baud rate. Typical baud rates include 9600, 115200, 57600...

2.2 k210 Vision Module

Kanzhi K210 is a system-on-chip that integrates machine vision and machine hearing capabilities. It uses TSMC's ultra-low power 28nm advanced process, has a dual-core 64-bit processor with total computing power up to 1TOPS, built-in various hardware acceleration units (KPU, FPU, FFT, etc.), and has good power performance, stability and reliability.

Function distribution is as follows:

image-20230926100744845

2.3 Hardware Connection

image-removebg-preview

K210 Vision ModuleMSPM0G3507
5V5V
GNDGND
TXRX2
RXTX2

image-20251029164030395

image-20251029164356332

image-20251029164049976

2.4 Environment Setup

We open the sysconfig tool and add configuration as follows

image-20251029165602353

PixPin_2025-11-05_18-36-38

PixPin_2025-11-05_18-37-20

K210 serial port configuration is as follows

image-20251029165639539

Enable receive interrupt

PixPin_2025-11-05_18-34-30

Add timer configuration for button detection

PixPin_2025-11-05_18-35-11

Enable zero event interrupt

PixPin_2025-11-05_18-35-36

2.5 Partial Code Explanation

bsp_key.c

bsp_k210_usart.c

K210 partial source code

Program Flowchart

Start
Development board KEY1 pressed
Development board KEY2 pressed
Development board KEY3 pressed
K210 RGB indicator switches three colors
K210 RGB indicator switches another three colors
K210 RGB indicator turns off

2.6 Main Functions

K210_Rgb_Key

Function Prototypevoid K210_Rgb_Key()
Function DescriptionControl the state of RGB light on k210
Input ParametersNone
Output ParametersNone

2.7 K210 Program Burning

Download all files in the [Program Source Code Summary] -> [Vision Application Experiment] -> [K210_SD_File] directory to the root directory of the memory card through card reader.

We can click on the tutorial link and select [Download] -> [Development Software] to access Google Drive and download the drivers and CanMV IDE .

image-20251029181000803

After successful installation, we connect microusb to K210 and computer. Open Device Manager and see similar device as shown below, which means our driver installation is successful. The COMX here depends on your actual situation, then we open CanMV IDE

image-20251029181125233

After downloading and opening CanMV IDE, we need to first drag the k210 source code provided in this course section k210_car.py to CanMV IDE to open, then connect IDE, here take helloworld.py as example

image-20251029180540342

After IDE connection is successful, the phenomenon is as follows

image-20251029181342135

Open the top menu bar Tools -> Save currently open script as (main.py) to CanMV Cam

image-20251029205906069

image-20251029181630720

Here you can choose Yes/No. The following status indicates successful writing.

image-20251029181701230

2.8 Experimental Phenomenon

After burning the program, press KEY1, KEY2, KEY3 buttons on the development board to switch the K210 indicator status once. KEY1 pressed makes K210 light up three colors, KEY2 pressed makes K210 light up another three colors, KEY3 pressed makes K210 indicator turn off.