How do I convert 51 code to STM32 driver code?[Copy link]
From: Embedded from 0 to 1 Author: Programmer Xiaoha
Origin of the problem
NOKIA 5110 Screen
The Nokia5110 screen is a very classic LCD display module. When Xiaoha was playing with microcontrollers, there were not many LCD modules to choose from, generally speaking, they were LCD1602 and LCD12864. In my opinion at the time, the Nokia5110 screen was a very advanced LCD screen.
Nokia 5110 screen is a liquid crystal display module used in 5110, 6150, 6100 and other series of mobile phones. Domestic manufacturers also produce similar compatible products.
In addition to mobile phones, this product can also be widely used in display systems of various portable devices, single-chip microcomputer control display, human-computer interaction interface display, data acquisition display and other electronic design occasions.
Specifications
Working voltage: DC3.3-5.0V
Screen color: monochrome
Resolution: 84*48, Characters: 6*8 characters, 6 lines of characters can be displayed, 14 characters per line
Communication mode: serial SPI interface
LCD module: LPH7366
Application: Single chip microcomputer detection information display, human-computer interaction interface development and other electronic designs
Dimensions: 45x43x1.6mm
Pin Definition
name
meaning
CLK
Serial clock line
DIN
Serial Data Line
DC
Data/Instruction Select
CE
Chip Select
RST
Reset
VCC
Power input (3.3V and 5V are both available)
BL
Backlight control terminal
GND
Ground
Module Schematic
Actual hardware connection
Nokia 5110
STM32 side
CLK
PC3
DIN
PC2
DC
PC1
CE
PC0
RST
PC5
VCC
3.3V
BL
3.3V
GND
GND
Module size
Program transplantation
Xiao Ha Ge has used a 51 single-chip microcomputer to drive this LCD screen before. In actual use, only five IO pins are needed to drive it.
Let's see today, if you can't find the routines for the chip you are using on the Internet, and there are only routines for other chips, how do you refer to them? Let's transplant them.
Copy driver files
Copy the driver file of the LCD screen to the HARDWARE directory under the STM32 project, and add the file to the STM32 project.
Compile the program, there is no error, download the program, and find that the preset content can be displayed normally on the screen, proving that the driver has been successfully transplanted.
This test used Dupont cables. Although Dupont cables are convenient, once they are touched, the screen display output disappears. I can only plug and unplug them again and reset the microcontroller. I am speechless.
Also, please note that sometimes, the contact of the DuPont wire is not very good. When testing the program, you must first ensure that the contact of the DuPont wire is good. If you are not sure, you can use the buzzer mode of the multimeter to test whether the two ends of each pin are conductive.
How is it? It is quite simple, right? If you have STM32 code, you can convert it to 51 MCU code in the same way.
In fact, the main problem is the adaptation of C language code between various microcontrollers, high portability, this would be fun if it were assembled