Interfacing 8051-based Microco

interfacing 8051-based microcontrollers
abstract: this application note describes how to configure the uarts 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 concludes with a practical example of how to configure an 8051-based dallas semiconductor microcontroller uart to communicate with an sci module.
introduction the serial communications interface (sci) is a high-speed serial i/o port that permits synchronous or asynchronous communication between devices. it allows a microcontroller to interface to a wide range of similarly-enabled peripherals, as well as a standard rs-232 interface. the exact implementation of the sci differs between device manufacturers; many devices accommodate features such as full-duplex communication in asynchronous mode, parity checking, error detection, and a programmable character length from one to nine bits.
all 8051-based dallas semiconductor microcontrollers are capable of communicating with sci-enabled devices, even though sci functionality is not explicitly listed on the microcontrollers’ list of features. all our microcontrollers incorporate one to three 8051-type uarts which can be configured to operate in most of the common sci modes. this application note describes how to configure the uarts 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 concludes with a practical example of how to configure an 8051-based dallas semiconductor microcontroller uart to communicate with an sci module. a code example is provided that demonstrates how to initialize the microcontroller and perform a simple test to ensure that the devices are communicating correctly. features of sci as mentioned above, sci is a high-speed serial interface. it has many similarities to the 8051-style uarts present on the dallas semiconductor 8051-based microcontrollers. the following is a list of sci features and their counterparts in the uart. the user should be aware that not all sci modules support all the features listed, so the user should carefully read the data sheet of the sci-enabled device to understand how it will be used.
feature sci dallas semiconductor uart
asynchronous mode available on most implementations serial mode 1, 2, 3
synchronous mode available on some implementations serial mode 0 only
character length 1 to 9, if optional character length is supported 8 or 9
parity available on some implementations supported by software in 9-bit mode
framing error yes yes
idle character detects idle characters to wake device. uart can not detect idle characters, but the uart microprocessor communication mode can be used to signal the uart to treat the next byte as an address/identifer.
break character sci can transmit and receive break characters (00h). can transmit break character by taking serial port rx pin to logic 0. receipt of break character may cause a framing error, depending on selected character length.
example most sci modules support the asynchronous communication format, many of them exclusively. the example here shows how to configure a dallas semiconductor 8051-based microcontroller to communicate asynchronously with an sci-enabled device. in this case we will configure the microcontroller to communicate with a target sci configured with the following characteristics:
10-bit asynchronous mode; 1 start, 8 data, 1 stop bit baud rate: 19200 bps to communicate with this device, we will make the following decisions for setting up the dallas semiconductor microcontroller:
use serial port 0 for communications external clock source is 22.1184mhz the serial port will be configured for 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). as all dallas semiconductor 8051-based microcontroller timers default to the original divide-by-12 mode of operation, this example has the advantage of being applicable to all dallas semiconductor devices, regardless of the clock divisor of the core. this is because the ds5000fp (divide-by-12), ds80c320 (divide-by-four), and ds89c450 (divide-by-1) all use the same serial port timing if the higher speed option for the timers is not selected. detailed information about operation of the uart can be found in serial i/o section of the appropriate user's guide.
because the sci has dictated 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 from a user-selectable timer overflow driven by the external clock source. this adds a considerable flexibility to the design and simplifies development because the baud rate is easily selected in software, permitting a number of baud rates from the same clock source. the equation for determining baud rate is shown below: where osc_frequency is the frequency of the external clock source in mhz, th1 is the 8-bit re-load value placed into the timer 1 msb sfr, and smod_0 (pcon.7) is the serial port 0 doubler enable bit. alternatively, the following equation can be used to solve for the value of the 8-bit reload number th1, if the baud rate and oscillator frequency are known: assuming an external clock source of 22.1184mhz, a th1 value of fdh will produce a target baud rate of 19200 with the doubler bit cleared. more information about baud rate selection can be found in serial i/o section of the appropriate user's guide. the following brief assembly code example shows how to initialize serial port 0 to communicate with an sci module configured for 10-bit asynchronous mode at 19200 bps. when operating successfully it will echo back any received characters. this function can be easily removed, making it a generic shell for any user-desired sci communication application. ;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 ; clr ti0 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. clr ri0 reti summary the uarts found in dallas semiconductor' 8051-based microcontrollers can easily be configured to interface with the sci module found in many devices. this popular serial interface can operate in a variety of modes, but the most common are the 10/11-bit asynchronous modes used in rs-232 communications. allowing dallas semiconductor microcontrollers to interface to sci modules increases the overall system flexibility, as they can be connected to a wider array of embedded systems.
although this example concentrated on the asynchronous mode of operation, dallas semiconductor microcontrollers can also be configured to interface with scis operating in the synchronous mode. the similarity of the sci module to the 8051 uart allows this interface to be accomplished with minimal effort. details about the synchronous mode (serial port mode 0) are found in the serial i/o section of the appropriate user's guide.

瑞科接近开关KP2接线图
如何更改在PCB上移动元器件的模式
Power Integrations推出LYTSwitch-6系列安全隔离型LED驱动器IC的最新成员
“百度云手机”旗舰版正式发布,77元/月
A0级以上新能源汽车市占率60%,全球齿轮制造大厂的数字化实践
Interfacing 8051-based Microco
VR培训公司Talespin推出“虚拟人技术”,用以培训员工人际交往能力
新iPhone会有哪些值得关注亮点
软件测试的方法有哪些有什么的规范
苏-35战机被我国“改头换面”,新型头盔既轻巧又坚固舒适度还很高
AMD独特Radeon FreeSync(显示变频技术)为你带来更卓越游戏体验!
基于MC145026和MC145028芯片实现水位检测系统的设计
motorola razr刀锋5G手机发布,将再塑行业工艺巅峰和设计标杆
精密温控型多功能光谱功率积分测试系统介绍
到2025年,恩施州将建成5G基站接近1万个
罗德公司研发无人机防御系统通过监测遥控信号频段阻止非法无人机活动
用LCR测量仪检测网络变压器为何要做短路开路和负载校正
PTN的组网与部署
电气工程师必需知道的人机界面知识
Seed-DUO黑胶智能音响评测 品味永远的经典