Welcome to STM32F103C8T6 core board repository
3.7.screen display experiment
3.7.screen display
1. learning target
1.Learn to understand the basics of iic communication.
2.Learn how to use the onboard 9.6-inch screen for displaying Chinese characters and character strings
IIC introduction of STM32F1:
The IIC bus is a bidirectional two-wire continuous bus that provides communication lines between integrated circuits. It means a protocol for completing the exchange of information between integrated circuits or functional units.
The IIC module receives and sends data, and converts data from serial to parallel, or parallel to serial. Interrupts can be enabled or disabled. The interface is connected to the IIC bus through a data pin (SDA) and a clock pin (SCL). Allows connection to standard (up to 100kHz) or fast (up to 400kHz) IIC buses. (The data line SDA and the clock SCL form a serial bus, which can send and receive data).
The IIC bus has three types of signals in the process of transmitting data, namely: start signal (START), stop (end) signal (STOP), and response signal (ACK). Second, it is idle when no data transfer is in progress.
The following is a simple interpretation of IIC communication combined with STM32f103
1.idle state:
For the initialization of SCL and SDA, we should set it to high level
2.When data transfer starts (start condition):
Start signal: When SCL is high level, SDA jumps from high to low. Here we should pay attention that the start signal is a level jump timing signal, not a level signal. From the above figure, we can see that SDA and SCL At the beginning, they are all high. When SCL is high, delay for a period of time to pull SDA low, and then wait for a period of time for SCL to become low.
3.end of data transfer:
End signal: When SCL is high level, SDA jumps from low to high, ending data transmission. The end (stop) signal is also a level jump timing signal. As can be seen from the above figure, a sign is required at the end of data transmission, indicating that the data transmission has been completed. First, we need to pull both SCL and SDA low, and wait for a while (SCL changes from low to high) to pull SCL high. During SCL is high SDA becomes high (so the following code will first pull SCL high and then pull SDA high)
4.Response signal: After receiving 8bit data, the IC that receives data sends a specific low-level pulse to the IC that sends data, indicating that the data has been received. After the CPU sends a signal to the controlled unit, it waits for the controlled unit to send a response signal. After receiving the response signal, the CPU makes a judgment on whether to continue to transmit the signal according to the actual situation. If no response signal is received, it is judged that the controlled unit is faulty.
5.slave PC reply:
Pull both SDA and SCL high, so that you can better judge whether the receiver returns a response signal, and judge whether the received signal is low in the while loop (that is, return a response), if not, wait for a while, within the specified time If it returns 1 without returning a response, it means that the response failed to be received.
6.master Reply
When the slave generates a response, the master changes from sending to receiving, and the slave changes from receiving to sending. Afterwards, data is sent by the slave, received by the master, each reply is generated by the master, and the clock signal is still generated by the master. If the host wants to terminate this transmission, it sends a non-response signal, and then the host generates a stop condition.
2. Hardware wiring connection
Note: If you do not purchase the package that includes the screen, you need to purchase the screen used in the experiment separately, otherwise you will not be able to complete this course due to the lack of important accessories.


Physical diagram of screen connection
3. program analysis
LCD initialization code:


screen fill code:

string display:

Chinese character display code:

image display code:

main function code:

The function realized by the main function is very simple, first call the LCD initialization function, fill the screen with white background, and then use the function to display character strings, Chinese characters and pictures.
4.Experimental phenomena
After the program is downloaded, the 0.96-inch screen will display "Hello!", "亚博智能" and the logo of the yahboom company.
