Design of LCD display based on communication between DSP and single chip microcomputer

Publisher:CoboroLatest update time:2011-10-24 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

With the rapid development of computer and information technology, digital signal processing technology has developed rapidly. Digital control makes power electronic conversion control more flexible. When the CPU computing speed allows, complex control algorithms that are difficult to achieve with analog control can be realized. Designers can easily change controller parameters according to their own system requirements. Even if the control object changes, there is no need to modify the controller hardware. Just change some software parameters, which greatly enhances the compatibility of the system. With the gradual popularization of DSP applications, DSP has been widely used in UPS and inverter control to replace dedicated PWM integrated circuits in analog circuits.

As intelligent equipment, human-computer interaction devices such as LCD screens and keyboards are indispensable for digital power supply systems. DSP has a high working frequency and a short read-write cycle. It is mainly used to handle critical tasks with strict real-time requirements and complex algorithms, such as the control of power switch tubes, data collection, analysis, and processing. The tasks of LCD display and keyboard scanning can be completed by ordinary 51 series microcontrollers, and the data exchange between DSP and 51 microcontrollers can adopt asynchronous communication mode, that is, the system adopts a dual CPU structure.

1 System structure principle

The DSP and MCU used in this paper are TI's TM S320F2812 and MCS51 series. In the system, DSP realizes asynchronous serial communication with MCU. MCU transmits the user's original setting data to DSP, and DSP returns the collected real-time data information to MCU. MCU continuously refreshes the LCD display. The basic structure of the system is shown in Figure 1.

Figure 1 System basic structure diagram

1.1 Serial port introduction

In this paper, DSP realizes communication based on the serial communication interface module SCI. SCI supports data communication between CPU and other asynchronous peripherals using standard format. SCI only needs 2 data lines for data transmission. Although the transmission speed is not fast, it can meet the general communication requirements, and the peripheral interface circuit is very simple. The length of the transmitted data is also variable within a certain range.

The MCS51 series microcontroller has a full-duplex serial port inside. The serial port has 4 working modes, which can be set by software. The baud rate is generated by the on-chip timer/counter. The serial port's receiving and sending data can trigger interrupts, and contains a receiving and sending buffer SBUF, which share the same address.

1.2 Communication interface circuit between MCU and DSP

The SCI interface is divided into two pins, RXD and TXD. Traditionally, two devices use RS 232 or RS 485 for asynchronous communication, and the corresponding RS 232 and RS 485 driver chips must be configured separately. However, in the digital power supply device with dual CPU structure mentioned in this article, the DSP and 51 single-chip microcomputer are located in the same device, and the distance is short. The RS 232 and RS 485 driver chips can be omitted, and the RXD and TXD of the two CPUs can be directly cross-connected. However, it should be noted that since the operating voltage of the DSP is 3.3 V, and the operating voltage of the MCS51 single-chip microcomputer is 5 V, the communication circuit between the two needs to be converted at a level, as shown in Figure 2.

Figure 2 Level conversion circuit

In this circuit, the voltage of the TXD terminal of the MCU is higher than that of the RXD terminal of the DSP, so only a voltage divider circuit is needed to calculate the appropriate resistance value to meet the requirements. When transmitting data from the DSP to the MCU, the level needs to be increased, so an optocoupler circuit is used to increase the level to the working level of the MCU. In this way, the level conversion can be achieved with a simple circuit. It should be noted that the optocoupler rate used must be higher than the data transmission rate, so as to ensure accurate and efficient data transmission to avoid data loss.

1.3 Software implementation of communication between MCU and DSP

In asynchronous communication, three things must be specified first: First, the character format, that is, the format of each frame of data transmitted; second, the communicating parties must be set to the same baud rate, and the baud rate must be able to adapt to the clock frequency of both parties; third, the communicating parties must have an agreed communication protocol, that is, both parties must confirm each other before transmitting data.

In this design, the data frame format used by DSP and MCU is 1 start bit, 8 data bits and 1 stop bit. Since the data packet is checked by checksum, no parity bit is set in the data frame format. Therefore, the MCS51 MCU should be set to work in serial port mode 1, and the serial port is an 8-bit asynchronous communication interface. In order to ensure that the data transmission has a high rate and a relatively low transmission bit error rate, the baud rate is selected to be 9600 b/s. The initial value of the register at the initialization of DSP and MCU can be calculated through the corresponding baud rate setting calculation formula to complete the setting. In this way, the unified frame format and baud rate of the two communicating parties are guaranteed, so that the data communication is correct and reliable.

The DSP serial port initialization setting procedure is as follows:

EALLOW;

GpioMuxReg s. GPGMUX. bit. SCIRXDB_GPIOG5 = 1; // Set the SCI??RX pin peripheral function

GpioMuxReg s. GPGMUX. bit. SCIT XDB_GPIOG4 = 1; // Set SCI??TX pin peripheral function EDIS;

ScibRegs.SCICCR.all = 0x07; // 1 stop bit, no parity, 8-bit character length, use idle line mode protocol

ScibRegs.SCICTL1.all = 0x 03; // Enable transmit and receive buffers

ScibRegs.SCICTL2.all=0x02; // Enable RXRDY interrupt, disable TXRDY interrupt

ScibRegs.SCIPRI.all = 0x0000; // Disable receive error interrupt and sleep mode

ScibRegs.SCIH BAUD = 0x01; // LSPCLK = 37.5 MHz, baud rate is set to 9 600 b/s

ScibRegs. SCILBAUD = 0xE1; ??

ScibRegs.SCICTL1.all = 0x 0023; // Re-enable SCI

51 The microcontroller serial port initialization procedure is as follows:

TMOD = 0x 21; // Timer 1 works in mode 2, used to generate the baud rate of serial port 0

SCON = 0x 50; //Serial port 0 works in mode 1, allows receiving, clears flag bit

TH 0 = 0xfd; // Crystal oscillator 12 MH z, set baud rate to 9 600 b/s

TH 1= 0xfd; PS= 1; //Serial port interrupt priority

PCON| = 0x 00; // The baud rate is not doubled

TR1= 1;

In this design, a self-defined communication protocol is adopted. First, DSP sends a handshake signal. After receiving the handshake signal, C51 enters the interrupt subroutine to determine whether the handshake signal is correct. If it is correct, the handshake is successful and the data packet is received. After receiving, the data is summed and verified. If it is correct, the display data storage area of ​​the LCD is refreshed; if it is wrong, the data is abandoned and the receiving data storage area is cleared to zero, waiting for the next communication. The program flow chart is shown in Figure 3.

Figure 3 Flowchart of the communication program between DSP and MCU

The timing sending procedure from DSP to MCU is as follows:

ScibRegs.SCITXBUF = Sci_VarRx[i]; //Write the data packet to the transmit buffer

i+ + ; // Send data packets in sequence

if (i == 12) i = 0; // Re-count

IER | = M_INT1; // Clear interrupt flag

ONE;

PieCtr lReg s. PIEACK. all = PIEACK_GROUP1;

51 The microcontroller serial port interrupt service program is as follows:

Rx0_Buffer[ Rx0_Ptr] = SBUF; // Read data into the receive array

RI= 0; // Clear the receive flag

Rx0_Ptr++; //Count up by 1

Rx_flag= 1;

Reference address:Design of LCD display based on communication between DSP and single chip microcomputer

Previous article:Design of instant messaging system client based on Android platform
Next article:Stepper Motor Driver Based on S3C2440 Embedded Linux

Latest Industrial Control Articles
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号