I have taken a lot of detours when using TFT screens recently. Since TFT screens are all 16-bit, most of them use a set of IO ports corresponding to 16 data bits to transmit data through parallel ports. Recently, due to the shortage of IO ports, I wanted to change to a serial port, but found that the serial port refreshes the screen too slowly, so I finally changed to an 8-bit parallel port. However, the registers for operating the IO port of STM32 are 16 bits. That is to say, if you use a parallel port, although only 8 bits are used to transmit data together, the operation is still 16 bits together. Although there are 8 bits that are not used, they are still operated together when transmitting data, and the values of the unused 8 bits will be overwritten together.
#define DATAOUT(x) GPIOB->ODR=x; //Data output
As above, when the macro is called, the entire B port is operated together.
Method 1: ODR configuration method, you can directly use GPIO->ODR = value << N; to perform output operations on the corresponding IO port. However, the hardware must ensure that: 1. The remaining IO ports on this function port (such as GPIOA) are not used as ordinary IO output ports 2. GPIO ports outside the rows and columns are either common IO input ports or function ports. Function ports are UART, USB, PWM, ADC, etc. When operating the ODR of GPIO, it will not affect the function port. That is to say, for example, if the high 8 bits of port B are selected, then IO ports 8--15 are selected to drive TFT, but IO ports 0-7 cannot be used as ordinary output IO ports, but can be set as input, or UART, USB, PWM, ADC and other functions.
Method 2
The IO port can be operated individually by bit operation, but the data refresh speed is very slow.
void WriteData(u8 data) { // Operate the IO ports connected to the LCD separately, the order is from high to low GPIO_WriteBit(GPIO number, Pin number, (data & 0x80) >> 7 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x40) >> 6 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x20) >> 5 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x10) >> 4 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x08) >> 3 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x04) >> 2 ); GPIO_WriteBit(GPIO number, Pin number, (data & 0x02) >> 1 ); GPIO_WriteBit(GPIO number, Pin number, data & 0x01); }
Using this method will not affect the bottom 8 bits, but the refresh speed will be very slow.
Previous article:STM32---Understanding of GPIO circuit structure (output circuit)
Next article:STM32 IO operation (based on library functions)
Recommended ReadingLatest update time:2024-11-16 12:00
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- PIC24F, clock frequency 8MHZ, after testing ONE_SECOND is not one second, what's going on?
- [TI recommended course] #[High Precision Lab] Operational Amplifier: 16 Fully Differential Amplifier#
- Which pins should be connected when adding the Bluetooth module to the IMX6?
- Understand the important role and characteristics of inductors
- [Qinheng Trial] Three CH549 uses pwm to adjust the brightness of the lamp
- Gallium nitride killer application: lithium battery protection!
- About C language conditional compilation
- 【National Technology N32G430】LCD-ST7735
- The STM32 video account and B station account have been opened. Are you paying attention?
- 【RT-Thread Reading Notes】Reflections on RT-Thread Chapter 9