The 8051 Microcontroller and Embedded

(lily) #1
Department of Computer Scien

ce and Information Engineering

National Cheng Kung University, TAIWAN
HANEL

ROTATE INSTRUCTIONAND DATA


SERIALIZATIONSerializing Data


(cont’)


‰Transfer a byte of data serially by


¾Moving CY to any pin of ports P0


– P3


¾Using rotate instructionWrite a program to transfer value


41H serially (one bit at a time)

via pin P2.1. Put two highs at the start and end of the data. Send the byte LSB first.Solution:

MOV A,#41HSETB P2.1 ;highSETB P2.1 ;highMOV R5,#8
AGAIN: RRC A

MOV P2.1,C ;send CY to P2.1DJNZ R5,HERESETB P2.1 ;highSETB P2.1 ;high

P2.1


CY


Register A


D7

D0

Pin

Free download pdf