Connect 8051 based microcontroller to SCI port

Publisher:TranquilSilenceLatest update time:2024-01-03 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This application note describes how to configure the UART of a high-speed microcontroller or ultra-high-speed flash microcontroller to communicate with an SCI-enabled device. It begins with a brief discussion of the differences between SCI and UART modules and ends with a practical example of how to configure an 8051-based Dallas Semiconductor microcontroller UART to communicate with a SCI module.


introduce

The Serial Communications Interface (SCI) is a high-speed serial I/O port that allows synchronous or asynchronous communication between devices. It allows the microcontroller to be connected to a variety of similarly functional peripherals, as well as the standard RS-232 interface. The exact implementation of SCI varies by device manufacturer; many devices support features such as full-duplex communication in asynchronous mode, parity checking, error detection, and programmable character length in <> to <> bits.


All 8051-based Dallas Semiconductor microcontrollers are capable of communicating with SCI-capable devices, even if the SCI functionality is not explicitly listed in the microcontroller's feature list. All of our microcontrollers contain one to three 8051-type UARTs and can be configured to operate in most common SCI modes.


This application note describes how to configure the UART of a high-speed microcontroller or ultra-high-speed flash microcontroller to communicate with a SCI-enabled device. It begins with a brief discussion of the differences between SCI and UART modules and ends with a practical example of how to configure an 8051-based Dallas Semiconductor microcontroller UART to communicate with a SCI module. A code example is provided that demonstrates how to initialize the microcontroller and perform simple tests to ensure the device is communicating correctly.


Characteristics of SCI

As mentioned above, SCI is a high-speed serial interface. It has many similarities to the 8051-style UART on Dallas Semiconductor 8051-based microcontrollers. The following is a list of SCI functions in UART and their counterparts. Users should note that not all SCI modules support all features listed, so users should carefully read the data sheets of SCI-enabled devices to understand how to use them.


featureSCIDallas Semiconductor UART
asynchronous modeWorks with most implementationsSerial mode 1, 2, 3
synchronous modeAvailable on some implementationsSerial mode only 0
character length1 to 9 (if optional character length is supported)8 or 9
parityAvailable on some implementationsSupported by software in 9-bit mode
Framing errorYesYes
idle characterDetect idle characters to wake up the device.The UART cannot detect idle characters, but the UART microprocessor communication mode can be used to signal the UART to treat the next byte as an address/identifier.
break characterSCI can send and receive interrupt characters (00h).Interrupt characters can be transmitted by converting the serial port RX pin to logic 0. Receipt of a break character may cause framing errors, depending on the selected character length.


example

Most SCI modules support asynchronous communication formats, many of which are exclusive. The example here demonstrates how to configure a Dallas Semiconductor 8051-based microcontroller to communicate asynchronously with an SCI-enabled device. In this case, we configure the microcontroller to communicate with the target SCI configured with the following characteristics:

10-bit asynchronous mode; 1 start, 8 data, 1 stop bit

Baud rate: 19200 bps

In order to communicate with this device we will make the following decisions to set up the Dallas Semiconductor microcontroller:

Use serial port 0 for communication

The external clock source is 22.1184MHz

The serial port will be configured in 10-bit asynchronous mode; 1 start, 8 data, 1 stop bit (this is serial port mode 1.

The baud rate generator clock source will be Timer 1 in auto-reload mode (Timer Mode 2).

Since all Dallas Semiconductor 8051-based microcontroller timers default to native divide-by-12 operating mode, this example has the advantage of being applicable to all Dallas Semiconductor devices regardless of the core's clock divisor. This is because the DS5000FP (divide by 12), the DS80C320 (divide by 4), and the DS89C450 (divide by 1) all use the same serial port timings if the timer's higher speed option is not selected. For details on UART operation, see the Serial I/O section of the appropriate user guide.

Since the SCI determines the format of the data, the Dallas Semiconductor microcontroller must next be initialized to the correct baud rate. The 8-bit auto-reload mode (Timer Mode 2) generates the baud rate via a user-selectable timer overflow driven by an external clock source. This adds considerable flexibility to the design and simplifies development since the baud rate can be easily selected in software, allowing multiple baud rates from the same clock source. The formula for determining the baud rate is as follows:

pYYBAGPy2H6AL0hRAAAHefSnmaY446.gif?imgver=1

where osc_frequency is the frequency of the external clock source in MHz, TH1 is the 1-bit reload value placed in the Timer 8 MSB SFR, and SMOD_0 (PCON.7) is the serial port 0 multiplier enable bit. Alternatively, if the baud rate and oscillator frequency are known, the value of the 8-bit reload number TH1 can be solved for using the following formula:

poYBAGPy2H-AAcPCAAAHZmrR-Us741.gif?imgver=1

Assuming the external clock source is 22.1184MHz, a TH1 value of FDh will produce a target baud rate of 19200 and clear the multiplier bit. For more information on baud rate selection, see the Serial I/O section of the appropriate user guide.

The following short assembly code example demonstrates how to initialize serial port 0 to communicate with an SCI module configured in 10-bit asynchronous mode at 19200 bps. On successful operation, it will echo any characters received. This functionality can be easily removed, making it a universal shell for any user requiring SCI communications applications.

;SCI emulation example

; Simple transmit test to demonstrate how to configure 8051 UART to

; emulate an SCI module. Test code embedded in this example echoes back

; received characters.


org 0h ;Reset vector.

ljmp start


org 23h ;Serial port 0 vector.

ljmp SP0_ISR



org 100h ;Start of code.

start: ;Initialize Serial Port 0 for mode 1, 19200 baud

MOV TMOD, #020h ;Set timer 1 for mode 2 (8-bit auto reload)

MOV SCON0, #050h ;SP0 10-bit asynchronous mode with receive enabled


;Now select the reload value based on baud rate and xtal frequency.

MOV TH1, #0FDh ;19200 baud at 22.11 MHz

;MOV TH1, #0FDh ;9600 baud at 11.059 MHz

;MOV TH1, #0FAh ;9600 baud at 22.11 MHz


SETB TR1 ;Serial port is initialized, now start timer


;Enable Interrupts

MOV IE, #90h ;This example supports interrupt-driven communications, so

                  ; enable global and serial port 0 interrupts.



;Test code in receive interrupt routine echoes back any received characters

; when combined with the loop here.

loop: sjmp loop



SP0_ISR: ;Serial port 0 Interrupt Service Routine

jb RI0, RIO_INT ;Determine if receiver/transmitter was cause of interrupt.


TIO_INT: ;Interrupt was caused by transmission.

;

; Placeholder for transmitter routine

;

CLRTI0

RETI


RIO_INT: ;Interrupt was caused by reception

;

; Placeholder for receiver routine

;


MOV A, SBUF0 ;Test code that echoes back received character

MOV SBUF0, A ; Remove for real code.


CLRRI0

RETI

Summarize


The UART in Dallas Semiconductor's 8051-based microcontrollers can be easily configured to interface with SCI modules in many devices. This popular serial interface can operate in a variety of modes, but the most common is the 11/232-bit asynchronous mode used in RS-10 communications. Allowing Dallas Semiconductor microcontrollers to connect to SCI modules increases overall system flexibility as they can be connected to a wider range of embedded systems.


Although this example focuses on asynchronous mode of operation, the Dallas Semiconductor microcontroller can also be configured to interface with an SCI operating in synchronous mode. The SCI module's similarity to the 8051 UART allows this interface to be accomplished with minimal effort. For more information about synchronous mode (Serial Port Mode 0), see the Serial I/O section of the appropriate user guide.


Reference address:Connect 8051 based microcontroller to SCI port

Previous article:8051 microcontroller interrupt system structure and interrupt control principle
Next article:Design of temperature and humidity acquisition system based on 8051 microcontroller

Recommended ReadingLatest update time:2024-11-22 04:41

Design of solar metal halide lamp control system based on C8051F920
In today's world where energy shortage and environmental pollution are becoming increasingly serious, how to effectively utilize clean solar energy is becoming an energy strategy for sustainable development in various countries. At present, most lighting equipment still uses traditional energy for lighting, so making
[Microcontroller]
Design of solar metal halide lamp control system based on C8051F920
8051 MCU Data Description
One of the keys to learning C51 is to deeply understand and apply the extensions of C51 to standard ANSI C, because most of the extensions are directly targeted at the 8051 series CPU hardware. The specific instructions are as follows (8031 is the default CPU). 1. Keil C51 extended keywords C51 V4.0 version has
[Microcontroller]
Analysis of the Problem of Program Loss in C8051Fxxx
Author: Hunan University Hu Yi Su Juan Zhou Haiyan 1 C8051fxxx microcontroller brief introduction and flash structure The c8051fxxx series of devices is a high-speed microcontroller series launched by Silicon Labs. This microcontroller is a fully integrated mixed-signal system-on-chip MCU chip.
[Microcontroller]
8051 MCU (STC89C52) - Changing the buzzer sound frequency
Since the interrupt handler of timer 0 is triggered once every 50ms, the frequency of the buzzer sound can be changed by changing the critical value when tcount returns to zero.  When tcount = 40 and the level is flipped, the sound produced is similar to the effect sound when the bus turn signal is turned on. When
[Microcontroller]
Make an alcohol tester based on 8051 microcontroller
We often see traffic police using breathalyzers to check whether drivers are under the influence of alcohol when checking for drunk driving. In fact, the alcohol tester is actually very easy to make. Here is how to make a homemade alcohol tester with a 3-digit display output. Of course, after all, it is used as a simp
[Microcontroller]
Make an alcohol tester based on 8051 microcontroller
8051 MCU pin diagram and pin functions
The following is the 8051 microcontroller pin diagram and pin function introduction:  《Microcontroller Pin Diagram》  The 40 pins can be roughly divided into 4 categories according to their functions: power supply, clock, control and I/O pins. ⒈ Power supply:   ⑴ VCC - chip power supply, connected to +5V; ⑵ VSS
[Microcontroller]
8051 MCU pin diagram and pin functions
Basic Hardware Circuit Design of C8051F MCU
In fact, C8051F does not need a crystal oscillator and a reset circuit, but in order to ensure the stable operation of the minimum system, it is best to add an external circuit. ● C8051F reset circuit design    The C8051F microcontroller has a built-in power-on reset, so the C8051F microcontroller can be reset norma
[Microcontroller]
Basic Hardware Circuit Design of C8051F MCU
Introduction to the usage of 8051 microcontroller instruction system
A computer's instruction set is the collection of all instructions it can execute. The 8051 instruction system has a total of 111 instructions, which are composed of 42 mnemonics and 7 addressing modes. 8051 instructions usually include two parts: opcode and operand. The opcode specifies what operation the instructi
[Microcontroller]
Introduction to the usage of 8051 microcontroller instruction system
Latest Microcontroller 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号