Download presentation
Presentation is loading. Please wait.
Published byCarol Edwards Modified over 9 years ago
1
ECE 353 Introduction to Microprocessor Systems Discussion 13
2
Topics Serial I/O Q&A
3
Problem Write a serial receive procedure, receive, that receives a 10-bit frame with even parity. The procedure returns the ASCII character in R0, and parity error status in R1 (0 = no error, 1 = parity error). Assume that two delay procedures are available, half_bit_time and one_bit_time. Also, assume that there is a 1 bit data port defined as INPUT, where you read the incoming data on D0.
4
Answer We will assume Asynchronous Serial Protocol A 10-bit frame will include: A one-bit start bit: 0 A 7-bit pattern – sent LSB first A parity bit – optional, used in this problem (The problem itself states the parity will be fixed, thus we will need the parity bit!) A one-bit stop bit : 1. Things to keep in mind: Is there a way to distinguish noise from an actual start bit? When is the best time to read the input to avoid errors due to noise or signal fluctuations or timing variations between receiver and transmitter?
5
Solution code “skeleton” receive PUSH{R2-R5, LR};context save LDRR2, =INPUT MOVR0, #0 MOVR1, #0 MOVR4, #0;keep track of parity MOVR5, #8;loop count - read bits poll_for_start get_bits parity_error frame_error done POP{R2-R5, PC};context restore/return END
6
Answer First, we will check for an actual start bit poll_for_start LDRR3, [R2];read data port ANDSR3, R3, #1;test D0 BNEpoll_for_start;still a 1 - check again BLhalf_bit_time;delay 1/2 bit time and ;check again LDRR3, [R2];read data port ANDSR3, R3, #1;test D0 BNEpoll_for_start;not still 0, keep polling
7
Answer Then, we de-serialize the pattern set get_bits BLone_bit_time;delay 1 bit time and get ;bit LSRR0, #1;prep for next bit LDRR3, [R2];read data port ANDSR3, R3, #1;test D0 ORRNER0, R0, #0x80;put bit in result ADDNER4, R4, #1;count 1 bits for parity calc. SUBSR5, R5, #1;decrement loop count BNEget_bits;loop til count = 0
8
Answer Check for frame error, check parity, return result, handle error in frame ;check for frame error BLone_bit_time;delay 1 bit time and get bit LDRR3, [R2];read data port ANDSR3, R3, #1;test D0 BEQframe_error;framing error parity_error ANDSR4, R4, #1;if D0 in R4=1, error, odd # bits MOVNER1, #1;set parity error for return BICR0, R0, #0x80;clear bit7 – just want data bits Bdone frame_error BLframe_err_proc;frame error - go to error handler done
9
RS-485 Differential transmission Transceivers usually have separate enables for transmit and receive – allows creation of a multi-drop bus Longer distances possible than with RS- 232 (roughly 4000 feet at 64K)
10
RS-485
11
Need a protocol to prevent bus contention – only one transmitter on at a time Master/Slave Token passing Bus turnaround speed is an issue – after completing a transmission, must disable the transmitter before another device enables its transmitter to send a reply or initiate a different transaction Overhead associated with a bus – must deal with traffic not meant for you – takes cpu time
12
Questions?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.