Hardware conditions: Use Zhongjingyuan Electronics 0.96-inch OLED, 7 lines are as follows:
VCC-------->Power Supply
GND-------> Ground
D0--------->SCK, connected to SCK of SPI1, PA5
D1--------->MOSI, MCU as host output, OLED as slave receiver, connected to PA7
RST-------->Reset interface, very important, PC0
DC--------->Command or data control line, connected to PC1
CS---------->PC2 chip select
The above is the wiring of OLED and STM32103. You can also use other SPI interfaces. Here, as long as D0 and D1 correspond to the SPI interface, the other lines are customized and can be used as ordinary IO port outputs.
Correctly configure the following interfaces to light up the OLED:
1. SPI interface initialization:
SPI is also a type of serial port, which is similar to the USART configuration. It initializes IO port multiplexing and IO and SPI clocks. If interrupts are required, it is necessary to configure interrupt priority, write interrupt functions, etc.
The sending and receiving are the same as USART. The data is first sent/received to a DR buffer, and then waits for sending/receiving, and uses the flag bit of the SR register to determine whether to send/receive.
2. Reading, writing and initialization operations of OLED.
There are many OLED initialization operations on the Internet. When you buy it, you will definitely be given all the initialization command processes, so just write it out. However, there is one thing, during initialization, you need to pull RST low first, then hold it for 50ms, and then pull it high.
Then comes the write command and write data operation. Write data and write command are determined by DC, high level writes data, low level writes command. Note that you also need to pull down the CS chip select. Then write the data to the DR buffer via SPI. There is another point here, OLED can only be used as a slave, you can only write to OLED, not read.
3. There are two important points: the polarity of OLED's CPOL. The one I use is 0, which means a high level in idle state; and the clock phase, which should be sampled at the first transition edge.
Then comes the screen clearing operation, which is actually lighting up each pixel. Just write 0XFF for all. What needs to be noted here is that the commands for reading and writing coordinates are written correctly. The OLED coordinates are 0-7 in the vertical axis and 0-127 in the horizontal axis.
If all the above configurations are correct, then the OLED can be lit up, and the rest is to figure out how to display characters, etc. I have always believed that as long as the screen is lit up, the rest is a matter of thinking. As long as the point drawing function is written, the points form lines, and the lines form surfaces. That's the reason.
Previous article:Keil compilation error about the use of __use_no_semihosting_swi
Next article:What can a microcontroller do?
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- RAQ #223: How to measure and determine soft-start timing without a soft-start equation?
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- GigaDevice's full range of automotive-grade SPI NOR Flash GD25/55 wins ISO 26262 ASIL D functional safety certification
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- New IsoVu™ Isolated Current Probes: Bringing a New Dimension to Current Measurements
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- Infineon Technologies Launches ModusToolbox™ Motor Kit to Simplify Motor Control Development
- STMicroelectronics IO-Link Actuator Board Brings Turnkey Reference Design to Industrial Monitoring and Equipment Manufacturers
- Melexis uses coreless technology to reduce the size of current sensing devices
- How many hours do you want to work on one of your jobs?
- Six methods to check short circuit of PCB circuit board
- After looking at the computer test papers for primary school students this year, I found that I am not as good as the primary school students.
- Toshiba Photorelay Evaluation - Dynamic Characteristics Test (Part 2)
- Qorvo to Exhibit at IMS 2021
- RS Ruisen Semiconductor's application in power tools and lithium battery protection boards
- Emitter follower principle and typical circuit
- How to use the standard library time_t time(time_t *seconds)? Is there a difference between the value obtained by the parameter and the return value?
- I'm bored, so I'll post a tutorial on LNA
- TI's 430 routines have various modules, so read them carefully.