Application of high-speed SoC microcontroller C8051F040 in dual-color LED screen

Publisher:SereneNature7Latest update time:2013-03-19 Source: 21IC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

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.

 

Application of high-speed SoC microcontroller C8051F040 in dual-color LED screen

[page]

(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.

 

 

(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;

}[page]

(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 the specific software flow chart 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.

Reference address:Application of high-speed SoC microcontroller C8051F040 in dual-color LED screen

Previous article:MCU serial communication program
Next article:Basic MCU Programming Exercises

Recommended ReadingLatest update time:2024-11-16 22:40

Design of USB-CAN Converter Based on CP2102 and C8051F040
introduction CAN (Controller Area Network) bus is a serial data communication protocol developed by Bosch in Germany in the early 1980s to solve the data exchange between many control and test instruments in automobiles. It is mainly used for various equipment detection and control. CAN bus is a
[Microcontroller]
Design of USB-CAN Converter Based on CP2102 and C8051F040
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号