1 High-speed SoC microcontroller C8051F040 features
The C8051F040 series devices are fully integrated mixed-signal system-on-chip MCUs with 64 digital I/O pins and an integrated CAN2.0B controller. Its main features are: (1) High-speed pipelined 8051-compatible CIP-51 core (up to 25 MIPS); (2) Full-speed non-intrusive in-system debugging interface (on-chip) 64 KB (C8051F040/1/2/3/4/5) in-system programmable Flash memory, (4K+256)B on-chip RAM, 64 KB addressing space for external data memory interface and hardware-implemented SPI, SMBus/I2C and two UART serial communication interfaces, integrated watchdog timer, VDD monitor and temperature sensor, C8051F04x series devices with clock oscillator are truly independent systems-on-chip. All analog and digital peripherals can be enabled/disabled and configured by user firmware. The Flash memory also has in-system reprogramming capability for non-volatile data storage and allows field updates of the 8051 firmware. Each MCU operates over the industrial temperature range (-45°C to +85°C) and operates at 2.7 V to 3.6 V. Port I/O, RST, and JTAG pins all allow 5 V input signal voltages.
2 LED hardware circuit and display working principle
2.1 Drive mode
When a forward voltage is applied to an LED device, the current flowing through it causes it to emit light. Therefore, the problem of driving an LED is transformed into the problem of how to make the PN junction in a forward bias. In order to control its luminous intensity, the problem of regulating its forward current must also be solved. The driving methods are divided into DC drive, constant current drive and pulse drive.
2.1.1 DC drive
DC drive is the simplest driving method. The operating point of the LED is determined by the power supply voltage, series resistance and the volt-ampere characteristics of the LED device. This driving method is suitable for situations where there are fewer LED devices and the luminous intensity is constant.
2.1.2 Constant current drive
The forward characteristic of LED devices is steep, and the dispersion of devices makes the forward current of each device different under the same power supply voltage and the same current limiting resistor, which causes the difference in luminous intensity. If the LED device is driven with constant current, the luminous intensity will be close as long as the constant current value is the same. The output characteristic of the transistor has a constant current characteristic, so the transistor can be used to drive the LED.
2.1.3 Pulse drive
Pulse drive is a method that uses the visual inertia of the human eye to repeatedly turn the power on and off to light up the LED device. Pulse drive is mainly used in two aspects: scan drive and duty cycle drive. The main purpose of scan drive is to save drive and simplify circuit. The purpose of duty cycle control is to adjust the luminous intensity of the device, which is used for grayscale control in image display. In practical applications, the two aspects are often used in combination.
2.1.4 Common LED display drivers
The serial control drive method is commonly used at present, that is, the displayed data is sent to the point drive circuit in serial mode, and 4953+74HC595 is mostly used as the driver.
2.2 Introduction to LED Hardware Circuit
The 256 B dual-color LED screen is mainly composed of 32 8×8 LED modules, 32 74HC595, 8 4953, 2 74HC245 and 2 74HC138. The LED screen is divided into interface circuit, drive circuit, decoding circuit and column data circuit according to its circuit. The interface circuit data line is introduced below.
A, B, C, D: row scan signal lines, which determine which of the 16 rows lights up;
R1, R2: red LED column data;
G1, G2: Green LED column data;
CK: 74HC595 serial data shift signal, the rising edge stores the data into the serial register in the driver module;
ST: 74HC595 data latch signal, the rising edge stores the serial data into the parallel data register, and the screen display is updated at the same time;
EN: 74HC138 chip select signal, the screen lights up when valid.
2.3 Introduction to LED working principle
2.3.1 LED Column Data Circuit Analysis
The LED screen is mainly composed of display dot matrix and row and column drive circuit. The display dot matrix is mostly composed of 64×32 boards. Due to the large number of LED light-emitting devices, a scanning drive method is usually used. The scanning drive circuit usually uses a set of column drivers for the same columns in multiple rows. The row of the row driver is connected to one end of the power supply, and the column of the column driver is connected to the other end of the power supply. When the row driver selects the i-th row and the column driver selects the j-th column, the corresponding LED is lit. The control circuit is mainly responsible for selecting each row in an orderly manner. Before selecting each row, the data of each column in the row must be prepared. When the scanning method is used for display, each row has a row driver, and the same columns in each row share a column driver. The row decoder gives a row valid signal, starting from the first row, and scans each row in sequence. Determine whether the column is turned on according to the data of the column latch, and the turned-on column lights up in the row. When the continuous scanning time of a row ends, the next row is displayed in the same way. After each row is scanned once, the next cycle of scanning starts from the first row. As long as the scanning cycle is shorter than the critical time of human eye flicker, the data change cannot be felt. This is an important ideological step in writing software.
The LED display uses 74HC595 as the column drive circuit. The chip has the following functions: It has an 8-bit serial-in and parallel-out shift register and an 8-bit output latch. The control of the shift register and the output latch are independent of each other. Therefore, when the first row of data is latched to the row line, the second row of data is organized by the shift register internally at the same time, which enables the row data preparation and display to be carried out simultaneously. For the column preparation data, it has the function of serial-in and parallel-out shifting, and for the column display data, it has the function of parallel latching.
2.3.2 LED row scanning circuit analysis
The row scanning circuit uses 74HC138 decoder, but due to the limited driving capability of the chip, 8 4953 chips (each chip can drive two rows) are connected to its output to enhance the row driving capability. The ABC 3 signal lines of the 138 decoder can generate 8-bit output signals. Each time a 4953 chip is selected, it corresponds to one of the rows. If the corresponding column latches the output data to the line at this time, the diode of the row is turned on and the data is displayed.
The LED dual-color board in this paper adopts 16-line scanning method, using ABCD 4 scanning lines combined with 2 74HC138 to generate 16-line scanning signals.
[page]
3 LED display screen requirements for single chip control system
For an LED display that can display normally and does not flicker, its normal refresh rate should theoretically be at least 50 fields/s. However, actual measurements show that only when it is greater than 55 fields/s (one field scan time is about 18 ms), the human eye will not feel flicker. For 64×32 LEDs, the time to process 1 B is 70.3 ?滋s, and the average number of instructions is Tb/1.5=70.3/1.5=47. The crystal frequency of C8051F040 is 22.118 4 MHz, the clock cycle is 0.045 ?滋s, and 70% of the instruction execution cycle of C8051F040 is 1~2 clock cycles, so the average instruction execution time is 2×0.045 ?滋s=0.9 ?滋s, which meets the LED display control requirements.
4 C8051F040 and LED hardware circuit
The connection diagram of C8051F040 and LED is shown in Figure 1.
This circuit uses the high 3 bits of the P2 and P3 ports of C8051F040 to control the LED display, where the high 4 bits of the P2 port are connected to the 4 address signal lines (ABCD) of the 138 decoder, namely P2.7 to A, P2.6 to B, P2.5 to C, P2.4 to D, P2.3 to G1, P2.2 to G2, P2.1 to CK, P2.0 to ST, P3.7 to EN, P3.6 to R1, and P3.5 to R2. The clock display circuit uses the PCF8563P chip and adopts the I2C bus control mode. SDA and SCL are connected to P1.3 and P1.2 respectively. The temperature circuit uses the 18B20 chip and adopts the single bus control mode. SDA is connected to P0.3.
5 C8051F040 LED Control Software Introduction
(1) Function Introduction
This display mainly introduces C8051F040 controlling LED split screen to display date, time and temperature. According to the hardware connection shown in Figure 1, the row scanning software address can be assigned as 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x20, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, and the row scanning will be performed according to the above addresses when writing the program.
(2) Software flow chart
The main program flow chart of C8051F040 controlling LED is shown in Figure 2, and the display program flow chart is shown in Figure 3.
[page]
(3) C8051F040 source code
The source program of C8051F040 is as follows.
(1) System clock configuration
void SYSCLK_Init (void)
{ int i = 0;
SFRPAGE = CONFIG_PAGE;
OSCXCN = 0x67;
for (i = 0; i < 3000; i++);
// Wait 1ms for initialization
while ((OSCXCN & 0x80) == 0);
CLKSEL = 0x01;
OSCICN = 0x00; }
(2) System port configuration
void PORT_Init()
{ SFRPAGE = CONFIG_PAGE;
//st SFR page before writing to XBR0 = 0x04
//Allow UART0, RX, TX to connect to 2 port pins XBR0 = 00000100 P1MDOUT = 0xf0; //Push-pull output
P2MDOUT = 0xff;
P3MDOUT=0xff;
P4MDOUT=0x00; //Open drain output
P4 |= 0xff; //Write 1 to disable low-side output driver
P0MDOUT |= 0x01; // Enable TX0 as push-pull output
XBR2 = 0x42;
}
(4) Connection between PCF8563 and C8051F040
The hardware connection diagram between PCF8563 and C8051F040 is shown in Figure 4.
(5) PCF8563 initialization process
The PCF8563 initialization flow chart is shown in Figure 5.
(6) Connection between DS18B20 and C8051F040
The hardware connection diagram between DS18B20 and C8051F040 is shown in Figure 6.
(7) DS18B20 temperature measurement system
The DS18B20 temperature measurement system flow chart is shown in Figure 7.
This article mainly introduces the working principle of LED display, hardware circuit composition and requirements for single-chip control system, etc., and uses the unique advantages of C8051F040 to achieve effective control of LED. It can directly drive LED without adding a bus driver on the control board, saving system resources. This article also gives specific software flow charts and source code, which can be connected according to the hardware connection diagram to display and run normally. This article has certain reference and application value in the application of LED display screens.
Previous article:A new type of electronic rudder angle indicator for coast guard ships based on single chip microcomputer
Next article:How to implement the serial port debugging function of the microcontroller in Proteus?
- 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
- ESP32-S2-Kaluga-1 Kit v1.3
- Solution to MotionFX getting stuck when executing MotionFX_initialize(); function
- W806 Lianshengde 9.9 yuan development board experience 4 --- SDK surprise discovery
- A Complete List of "English Abbreviations" in Hardware Schematics
- A little skill can satisfy high return income. Let's share a product repair with super high click rate
- Why use ultrasonic testing for flow meters?
- How KiCAD schematics and PCB interact
- About Power
- Usage of $test$plusargs
- Amplifier Expert Design Experience