STM32_SDK Quick Start
Last updated
Last updated
Please check the below link to download
This routine introduces how to use the STM32Core platform CAN function IO pin to connect Witt intelligent HWT9053CAN sensor, and then directly print data through serial port 1, receive sensor data and communicate with the sensor; Before viewing this routine, please read the relevant sensor manual to understand the protocol used by the sensor and the basic functions of the sensor
First of all, prepare WitMotion HWT9053CAN sensor, STM32Core development board and a serial port 3 in 1 adapter. Please check the below wiring:
Download the program to the development board, open the serial port debugging assistant at the same time, and power on again, the following information will be displayed:
You can send corresponding instructions to configure the module through the prompt information
The sensor data of the CAN protocol will also be uploaded automatically.
For the introduction of API functions, please read the WIT_C_SDK API function documentation.
Usart1Init(115200); //Initialize the print data serial port
WitInit(WIT_PROTOCOL_905x_CAN, 0x50); //Initialize the high-precision CAN protocol and set the device address
WitRegisterCallBack(SensorDataUpdata); //Register to get the sensor data callback function
WitCanWriteRegister(Can_Send_Msg); //Registers a callback function that writes out data
WitDelayMsRegister(Delayms); //Register delay function
AutoScanSensor(); //Automatically search for sensors
We will create an array to store the read data into the array, and read the corresponding data directly according to the index. If the module automatically lasts data, the status data update will read the data returned by the sensor, and the final effect is to read the data of the module's 3-axis acceleration, 3-aixs angular velocity, 3-axis angle, and 3-axis magnetic field into the specified index array. Finally print it out.
The parameters of the module can be set through the function CmdProcess(); Such as acceleration calibration, magnetic field calibration and modification of CAN baud rate, etc.
Open the serial port assistant, send the command r\r\n, and then observe the phenomenon.
After sending r\r\n, modify the return rate to 1Hz. It can be seen from the timestamp that the data is returned every 1s. Compare the sending instructions introduced in the HELP prompt information. The baud rate indicates that the setting is correct. Use other commands as needed.
Some common API function interfaces are defined in the file wit_c_sdk.c, which only needs to be called.
After sending a\r\n through the serial port assistant, after waiting for about 5 seconds, the X and Y axis angles will be calibrated to a state of about 0 degrees. Acceleration X, Y calibration is about 0g, Z is about 1g.
After sending a\r\n through the serial port assistant, after waiting for about 5 seconds, the X and Y axis angles will be calibrated to a state of about 0 degrees. Acceleration X, Y calibration is about 0g, Z is about 1g.
Please reference to the sensor datasheet.