New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Class Note for ECE 4436 at UH


Class Note for ECE 4436 at UH

Marketplace > University of Houston > Class Note for ECE 4436 at UH

No professor available

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

No professor available
Class Notes
25 ?




Popular in Course

Popular in Department

This 27 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Houston taught by a professor in Fall. Since its upload, it has received 18 views.

Similar to Course at UH


Reviews for Class Note for ECE 4436 at UH


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/06/15
15 amp 18 Serial IO Dept of Electrical amp Computer Engineering University of Houston ECE 4436 ECE 4436 What is Serial IO Serial IO refers to using a serial communications interface and protocol between the computer and an external device Minimally 23 wires TransmitReceive and Ground Many PC peripherals such as printers have required a serial connection although USB is rapidly displacing serial in devices Serial is still frequently used between an MCU and small external devices such as an LCD because of the hardware simplicity and efficiency The programmer on the MCU however sees the builtin serial communications interface like any other parallel levice PA7 PEO PB7 WWWW WM w T 2m 3 Egg 16K 32K 64K 96K 128K byte Flash Analog ANZ Digital Convener mi lt gt MuduleATD H 1K2K 4Kbyte RAM m2 lt gt AN7 4 Background T BC 0 Debu Hcs12 Imer C1 0 Mom ModulgeEDM CPU Module IOC2 ltgtMUx TIM IOC3 4 PLL Wm 3988 ClockandRe Generation Mo Programmmg the 8g 3 Hardware CRG SCI looks n medley 2WD communication p W between MCU and llke any othel b1111t m W4 gt 39 39 E g m devwe W5 external Idev1ce 13 D39 4 as o serlal lt gt PJG E E E0 PJ7 4 X I he ADR1 DB1 051 4 ADRZ DB2 052 W x RXD lt w 4 p50 g lt lt gt ADR3 DB3 Das TXD gt m 9 4 PS1 I E 4 ADR4 D54 D54 3 EL 4 P82 0 4 ADRS DEE 085 4 PS3 lt gt 23 BS 339 RXCAN PMO lt gt Anna DEB MSCAN TXCAN gt 2 ltgt PM1 M E lt gt PM2 0 ADRQ DES MISC 39gt D n PMS 0 ADR1U 0810 SP1 ss L lt gt D quot g E 4 ADR11 mam Mo SI 4 0 m 0 EL lt gt ADR12 0512 SCK lt gt 0 D lt gt ADR13 D313 lt gt ADRM gt514 lt gt ADR15 g 0315 O m C 1239 m M 9 S 1 2 3 AddressDam Z g Figure 41 MCBS1ZC family biock diagram ECE 4436 Serial vs Parallel Let s take the example of transmitting a byte of data Parallel The 8 individual bit values are placed on 8 separate wirespins and transmitted simultaneously There are usually additional control and status signals High speed but expensive and bulky Example SCSI ATAPI writing to port PTT on the MCU writing to memory Serial The 8 individual bit values are placed on a single wirepin one at a time in succession Again there must be additional control and status signals or a builtin synchronization technique Slower than parallel but cheaper and more practical Examples RS232C USB ECE 4436 Duplex Communications Communications can be Simplex Communication always in only one direction EX TV or radio broadcast Halfduplex Communication in only direction at a time EX Pushtotalk walkietalkie singlelane bridge Fullduplex Communication in both directions simultaneously EX Telephone ECE 4436 Synchronous vs Asynchronous Communicatih Synchronous As the bit values are transmitted on the data Wires an additional Wire transmits a clock signal that indicates when the data bits may be changing All parallel communication is synchronous SP1 on the 9812 Isochronous The clock signal is derived from the speciallycoded data signal itself Ex Firewire USB Asynchronous Synchronization overhead start stop bits is inserted into the bit stream so that the receiver can repeatedly resynchronize EX RS232C SCI on the 9812 ECE 4436 Asynchronous Seria Data Format Mark 3 to15v Space 3 to 15 v f 4 T gt4 gt4 gt4 5m 7 dam bIts Parlty Stop RS Z32C M M voltage One chamer levels Example Ag M 00 0 even parlty Mark 3t015 V Space3to15 v 4 gt4 gt4 gt4 5m 0 0 0 I 0 Stop bIt Parlty bIt bIt Bit 0 follows the start bit ECE 4436 TABLE 183 Summary of RS ZGZ C RS423 R8422 and RS485 Standards Specilicatiun RS232C HS423 ns 422 HS485 Receiver inpm Voltage 200 mV lo 12 V 200 mV to 7 V 201mV xo 77 m 3 V DIich39nulpmsignul utliv 36LuyV 12m SV 1 new Maximum data rate 20 km Ion lib5 10 Mbs 11 Mbs Mnxlmuln cable length so so 4000 rue 400m real 4000 Feel Dri vsomcaimpcdancc 377 kn JSOIZmin 1000 mecr inpul re nance 1 m 4 kn 4 m n Mode Singlcrcmlczl Singlcrcndcd Dir inl Numbcrol39drivclsaml I Driwr I Driver 1 Driver Icceivers allowed on I Receivcl 0 Receivers 10 Receivers 32 Receivers one line Note that RS232C is an older standard with performance very limited compared to these newer standards 0 However for nondemanding applications it is simple and cheap and thus still widely used E g computer printer RS232C Devices TxD TxD Data RxD lt RxD Data Terminal SG SG Communications 39 E 39 t Equment RTS RTS qu1pmen CTS lt CTS Serial a Came TxD TxD Date RxD d X b RxD Data Terminal SG 86 Tarmine Equipment RTS RTS Equment CTS lt gtlt gt CTS Null Modem b Came Figure 1815 Serial communications a DTE DCE andbDTE DTE ECE 4436 modern ECE 4436 RSZ32C Signal De nitions TABLE 182 RS232 C Signal Definitions DEQ D325 Signal Purpose l PG Prura39livr Ground This is usually the shield in a shielded cable It is designed to be connected to the equipment frame and may be connected to external grounds 3 2 TXD 7iutrmillezl Dam Saurccd by DTE and received by DCE Data terminal equipment cannot send unless RTS CTS DSR and DTR are asserted 7 3 RXD Received Dam Received by DTE sourced by DCE 4 RTS Requexl Ir Send Sourced by DTE received by DCE RTS is assetted by the DTE when it wants to send data The DCE responds by asserting CTS 8 5 CTS Clear to SEMI Sourced by DCE received by DTE CTS must be asserted before the DTE can transmit data 6 6 DSR Data Set Ready Suurced by DCE received by DTE Indicates that the DCE has made a connection on the telephone line and is ndy to receive data from the terminal The DTE must see this asserted before it can transmit data 5 7 SG Signal Grmmd Ground reference for the signal is separate from pin I protective ground I 8 DCD Dmu CurriequotDram Sourced by DCE received by DTE Indicates that a DCE has detected the can39ier on the telephone line Originally it was used in halfduplex systems but can be used in fullduplex systems too 4 20 DTR Dam vaninul Ready Sourced by DTE received by DCE Indicates the DTE is ready for sending 0r receiving 9 22 RI Ring lnzlit39umr Sourced by DCE received by DTE Indicates that a ringing signal is detected ECE 4436 Serial Communications Interface SCI on the MCU 39PORT 839 Serial Receive Data SCI RXD 4 P80 4 CMOSto eria ransmi a Rs232 TXD gt 1381 R3232 gt Serial Psz Lave Request to Send Device Converter PS3 l Ciearto Send 7b i Figure 1814 HCS12 Serial Commu ications Interface SCI Eg MAX3232 Line DriverReceiver ECE 4436 RS232 Line DriverReceiver V MAX3232 DD 1 21 VDC 16 I 01 W 2 3 1 1 V 6 0 1pF n1pF 01pF Dam l 4 32 1 Terminal mm fl Equipment 39PORTS39 5 02 LR 6 SCI RXD lt rPso 1 1 mom R1IN 3 RXD 1 2 7 3 TXD gt PS1 b 11 T1N T10UT 1 TXD a a P82 9 RZOUT mm a L PS3 1 T2N new 7 I1 5 GND CTS RTS Figure 1817 SCI wnh R872327C interface ECE 4436 SCI Data Registers DoubleBuffen39ng 39SCIDRL39 READ R7 SerialDZt39ageived R0 SCIDRH R7 s i iler R0 RXD serial in R5 T8 out quot gt 7 JASPEESES39H To gt W A 1 17 Senal Eggsmmed To 39SCIDRL WRlTE Figure 152 SCI data registers k ECE 4436 SCI Registers Programming the SCI SCIDRL Write the output character to this register or read the input character from this register SCICR2 Control register 2 enabledisable interrupts enable disable transmitter and receiver SCISRl Status register 1 transmitter data register empty ag receiver data register full ag error ags SCIBDHSCIBDL Baud rate selection PTS This is Port S if you are simply using PTSOPTS3 as digital IO bits not through the SCI See Register De nitions in HIZQIE Sif l Blow Guide on the course web site ECE 4436 T Unlvelsal Asynchronous RecelverTransmltte 1f your CU doesn thave bulltm SC TX A Motorola 6850 ACIA CW mu m swam germum 4 E u 5 mmmmar mmglsmr 7 n ulummr a PM n nn dd d dn mumm m 10 Gwyn 9 a 41 CST mm Tmnlml nrm l 7 Rs 11 mm NW 13 mxmuu He smuzmo L we a cr39smns WEN E DCD RDRF multif on a Dumlnnlmr m 5 ENE 5 5 4 3 2 1 0 1 x m n M Chi RaeW6 P m mm um cam my D m quotWMquot c ml 1 gamm D 11 T D 15 lewrdlhml nr Roam 2 D1 15 Y al l l dl d du quotWWW T m 3 mm Imamam M germM 7 Loalo v v ECE 4436 Device Drivers A device driver is a software module containing subroutinesfunctions with the common purpose of providing lowlevel access to a particular IO device The driver is generally the only interface between the other software components in the system and the hardware of this device All accesses to the device must come through this driver The functions are normally created in the same file The public interface consists of the external functions Other functions may be private local static called only by other functions in the le The functions may share private local static data ECE 4436 Driver Files Drivers written in C devicec The driver le containing all of the functions public and private static deviceh The header le containing the prototypes of the public functions This le is included by other modules that use the driver Drivers written in assembly language deviceasm Contains all of the subroutines public and private The public subroutines are declared external using XDEF deviceh If these subroutines are designed to be C allable they will need function prototypes here ECE 4436 SCI Driver Example Assembly Language initsci Sets SCI baud rate and other parameters and enables the SCI for transmit and receive putsci Transmits a single character scicharready Checks to see is a character is ready to read and reads and returns it if it is gets ci Waits for then reads and returns a character sci inc An included le that contains SCI register and bit definitions such as RDRF TBRE B9600 These are written in assembly language such that they are also callable from C Of course they could also be written in C Two files scidriverasm and scidriverh for C o o 0 0 File sci driverasm INCLUDE quotsciinc port definitions Initialize SCI to 1 start 8 data and 1 stop bit no parity and 9600 Baud Inputs None Outputs None XDEF initsci initsci init sci initsci pshd Save D reg Set 1 start 8 data and 1 stop bit bclr SCICR1MDDE Disable parity for no parity bclr SCICR1PE Enable transmitter and receiver bset SCICR2TERE Set Baud rate ldd B96OO std SCIBDH puld Restore D rts Put char to SCI Send data to SCI Inputs B register data to send Outputs None kirkkirkkirkkirkkirk XDEF put sci putchar putsci putchar Wait until the transmit data reg is empty spin put brclr SCISRlTDREspin put Output the data and reset TDEE stab SCIDRL rts o o o o o o o o o o o o o o o o o Check for character in SCI receiver Check the RDRF flag If a character is ready returns with Cl the character in the B register and the status information in the Aregister Otherwise CO and the Aand B regs 0 Inputs None Outputs B character Carry bit T or F A status information When called from C an int is returned with status in the high byte A and the character in the low byte B If the low byte is zero no character is ready XDEF XDEF scicharready scicharready scicharready scicharready continued on next page scicharready cont d kirk XDEF scieharready XDEF scicharready scicharready scicharready clc Clear carry clra Clear A clrb Clear B IF RDRF is set brclr SCISR1RDRFexitready THEN the character is there ldab SCIDRL Get the data ldaa SCISRl Get the status sec Set the carry ENDIF exitready rts Get char from SCI Get a character from SCI waiting for it Inputs None Outputs B character v rv rv rv r XDEF getsci getchar getsci getchar psha spinget IF a char is there waiting jsr scicharready bcc spinget ELSE wait THEN get it and return ldab SCIDRL pula rts File scidriverh ifndef SCIDRIVERH define SCIDRIVERH SCI Driver header file Public Function Prototypes void initsci void void putchar char int scicharready void char getchar void endif end of SCIDRIVERH Calling scicharready from C 7 8 9 0000 10 11 12 0001 13 14 0004 0007 15 0009 000b 16 000e 0010 char data unsigned char status void mainvoid 3b 2 int result First init the sci initsci 160000 4 JSR initsci Check if character is ready result scicharready PSHD 160000 4 JSR scicharready 6c80 2 STD OSP data charresult low byte e681 3 LDAB 1SP 7b0000 3 STAB data status charresultgtgt8 hi byte e680 3 LDAB OSP 7b0000 3 STAB status ECE 4436 SCI Utility Functions There may be other functions that do SCIrelated operations but if they always go through the SCI driver functions they are not properly part of the driver itself For example the function on the next slide putstr writes a string of characters to the SCI using the putchar function from the driver putstr is in a separate file putstrasm and references the driver s putchar function through an XREF File putstrasm Put null terminated string to SCI Inputs D starting address of string Outputs D number of characters printed o XDEF putstr XREF putchar putstr pshx pshy tfr dx Initialize pointer to string ldy 0 Initialize counter WHILE character to print is not a null while do ldab 1x beq done DO Print the character jsr putchar iny increment counter bra whiledo o o done tfr yd return with character count puly pulx rts


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Jennifer McGill UCSF Med School

"Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over $500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.