Serial port output

1. Learning objectives

Detect through the linear CCD module and print to the computer's serial port assistant through the serial port.

2. Hardware connection

Linear CCD module, USB to TTL and MSPM0G3507 wiring

Note: If there is no TTL module, you can also use the type-c serial port directly

3. Program description

Define the header file for serial port transmission of one byte

Define the serial port initialization function, the function to send one byte of data, and the serial port interrupt service function.

Header file declaring millisecond and microsecond functions

 

Millisecond and microsecond delays are achieved through tick timer counting

 

Declare the linear CCD data acquisition function, ADC related functions and serial port printing function

The ADC conversion is triggered by software, and data is collected after the conversion is successful. Finally, the collected data is printed out through the serial port.

Initialize the serial port, enable ADC interrupt, start ADC conversion and obtain data in the sendToPc function. Finally, print the data of the CCD module on the serial port every 10 milliseconds.

Note: The project source code must be placed in the SDK path for compilation.

** For example, the path: D:\TI\M0_SDK\mspm0_sdk_1_30_00_03\1.TB6612**

4

4. Experimental phenomenon

Burn the program to MSPM0G3507 and connect the wires according to the wiring diagram. Close other programs that occupy the serial port, open the serial port assistant on the computer, select the serial port number, and set the baud rate to 115200. In the serial port assistant, you can see the printed CCD data. The figure below is the CCD data printed by the serial port assistant. You can see that the first 15 data are too small, so some places will skip the first 15 data when the algorithm is processed later, so as to ensure the stability of data calculation.