Software design of bluetooth microcontroller  tws earbuds factory reset

Software design of bluetooth microcontroller  tws earbuds factory reset

Publish Time: Author: Site Editor Visit: 1141

Software design of bluetooth microcontroller  tws earbuds factory reset

The software of the single-chip microcomputer adopts the programming of embedded C language, and the development environment is Keil. In this design, only the basic data transmission of Bluetooth can be completed. This part of the software includes three parts: initialization, Bluetooth interaction, and data processing. bjbjaudio.com    <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

Initialization includes system initialization and Bluetooth initialization. System initialization includes system clock initialization pin assignment, serial port initialization, timer initialization, etc. Bluetooth initialization is to send a series of initialization commands to the Bluetooth module through UART, the Bluetooth module returns events, and interactively completes a series of resets, authentication, read addresses, etc. Initialize operation. bjbjaudio.com           <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

Bluetooth interaction means that after the initialization is completed, if the local Bluetooth is used as the slave device, it will wait for the link establishment request of the remote Bluetooth device. If the request is accepted, it will continue to wait for the successful link establishment and obtain a connection handle, so that data exchange can be performed. As the master device, a series of operations such as active query, link establishment, data transmission, and link disconnection are performed. bjbjaudio.com   <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

Processing data is a series of subsequent operations such as dumping valid data to the corresponding location. It should be noted that in the main loop of the program, it is necessary to judge whether there is data in the serial port receiving buffer in real time, and call the HCI state machine for processing if there is data. bjbjaudio.com         <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>


Before entering the bluetooth basic data transmission experiment project, a flag bit btrole is set, and the user can choose the role of the local bluetooth to enter the experiment as a master device or a slave device. Whether it is a master or a slave, the Bluetooth initialization part is the same. bjbjaudio.com                <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

After the initialization is completed, when the local Bluetooth is used as the master device, it must first initiate a query. After the remote Bluetooth device is inquired, it must actively initiate a connection. After the connection is established, the data can be transmitted between the local Bluetooth and the remote Bluetooth. The local bluetooth is sent to the remote bluetooth, and the remote bluetooth can also be sent to the local bluetooth. When the local Bluetooth is used as a slave device, it cyclically waits for the connection request of the remote Bluetooth. After receiving the connection request event, it notifies the user to decide whether to accept the connection request. If accepted, send HCI AcceptConnection, if rejected, send HCIrejectconnectionrequest. After the Bluetooth connection between the single-chip computer and the PC is established, data can be transmitted between the two. Since the single-chip computer does not support data input, the system uses the PC side to input data and send it to the single-chip computer. After the single-chip computer receives the data. This involves the detection and processing of data. bjbjaudio.com   <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

The HCI state machine goes through a series of processing after detecting the arrival of the ACL data packet, and stores the actual data in a data receiving buffer. can be dealt with in a timely manner. When the MCU side is used as a slave device, if it is set to automatically return open, it can also return the received data to the PC. bjbjaudio.com    <a style="opacity:0.0;color:#ffffff">tws earbuds factory reset</a>

micro stepper motor dc motor encoder planetary gearbox manufacturers gear reduction motor