A data collector based on STM32F107 design is designed to realize a variety of data (serial port, CAN port) acquisition and processing, and wireless upload through GPRS module. The CAN device driver was written in detail; the device data was used to upload and download the serial port data of the GPRS module; finally, some problems occurred during the process of using the thread were proposed. The system function is shown in Figure 1, not too complicated. Due to the large amount of data reported by the lower-level sensor module, the content of the writing processing program is large. In order to modularly process the active reporting data of the sensor, the CAN device no longer uses the previous interrupt processing, but uses the RTT device framework to rewrite the device driver. Study CAN bus transceiver equipment in RTT: Found only the framework, no content. Just write a candevice like a serial port. Study the serial port driver in use of the component: This is a process of reading the code. After figuring out the framework, write a driver similar to linux. After all the above programs have been written, you can use the device general operation function to operate the CAN. In the main program, you first initialize the device and then register the device. The GPRS module is actually used to receive the serial data. First create a gprswatch process to monitor the serial port to receive data. In the monitoring GPRS serial port thread, after receiving the serial port data, it receives and analyzes and sets the network status. The monitoring and operation of the corresponding GPRS module is completed elsewhere in the program. A device operation function is also written for the GPRS module read and write operations, mainly using the gprswatch thread previously written: So far, the device operation of the GPRS module has been basically realized. In the RTT project, the int rt_application_init(void) function gives a basic use, dynamically creating the thread rt_thread_create, dynamically allocating memory. In the process of programming, because the memory is too small, you have to divide the allocated memory. The manual recommends using commands to view the memory occupied by the thread during the running of the program, and then divide the memory according to experience. In this way, there are many errors in the debugging process. Later, I flipped through the manual and copied the example to modify the program to create a statically allocated thread. rt_thread_init, the above error no longer appears. Finsh is used extensively during the debugging process, which greatly facilitates debugging. Refer to the instructions in the user manual: Write a function that can be exported to finsh if it is not running in the program. In the serial console operation, it is convenient to debug the GPRS related functions, and the above functions need to be run in the main program. RTT-based STM32F107 platform routines were written and posted on github: https://github.com/sundm75/STM32F107Board-rttproject Each application in the example has a corresponding test**** file. In this file, all used finsh operates in serial port control. - End - Ultrasonic Annunciator,Ultrasonic Piezo Annunciator,Outdoor Ultrasonic Annunciator,Ultrasonic Piezoelectric Annunciator NINGBO SANCO ELECTRONICS CO., LTD. , https://www.sancobuzzer.com
Author Sun Dongmei: Ph.D. and Associate Professor, School of Automation and Electrical Engineering, Nanjing University of Technology