Microprocessor%20Systems%20II%20Project

33
croprocessor ystems Project Functionality : Every second, display time & temperature on LCD line 1 (& on PC terminal, via serial port, if time permits). Include timer set control via keypad. Read On-chip temperature sensor every second using built-in ADC (Analog to Digit al Convert er). Devi ce pin not required since temp sens or is on chip. Timer control (using keypad keys A, B, C, D) : A: Update time mode (ON/OFF) B: toggle time field (Hr10 -> Sec1) C: increment selected time field D: decrement selected time field E: apply changes and return to normal operation Keypad actions are monitored and take effect only at one second intervals 13:43:27 T=000 24-hr clock display On-chip temp sensor value LCD line 1

Transcript of Microprocessor%20Systems%20II%20Project

Page 1: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 1/33

croprocessor ystems

ProjectFunctionality : Every second, display time & temperature on LCD line 1 (& on PC

terminal, via serial port, if time permits). Include timer set controlvia keypad.

Read On-chip temperature sensor every second using built-in ADC (Analog toDigital Converter). Device pin not required since temp sensor is on chip.

Timer control (using keypad keys A, B, C, D) :

A: Update time mode (ON/OFF)B: toggle time field (Hr10 -> Sec1)C: increment selected time fieldD: decrement selected time field

E: apply changes and return to normal operationKeypad actions are monitored and take effect only at one second intervals

13:43:27 T=00024-hr clock display

On-chip temp sensor value

LCD line 1

Page 2: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 2/33

Microprocessor Systems II

ProjectHardware : ADuC831 (on-chip temperature sensor/ADC/Timer)

Keypad, LCD unit

Software : Aspire

Support documentation :Microconverter data sheet (ADuC831.pdf)

ADC circuit information pp 18-24 (includes reference to temperature sensor)

UART Serial interface, pp 55-58

PC Software : C:\ADuC\9600com1.ht (preconfigured hyperterminal program)

Page 3: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 3/33

ADuC831 B oc D agram

-chip

mperature

nsor 

rial port (if 

e allows)

Timer 0 [generate 1 sec interrupt, use to trigger 24 hr tmr 

updates, temp sensor reads, LCD writes]

Page 4: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 4/33

nalog-to-Digital Converter (ADC)ectronically translates analogue signal

to digital quantity

igital-to-Analog Converter (DAC) translates

igital quantity into analogue signal

Often used together in digital

systems to provide complete

interface with analogue sensor and o/p devices for control

s sRef : www.allAboutCircuits.com/vol_4/chpt_13/

Page 5: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 5/33

Microprocessor Systems II

Project AssignmentSuggested approach/tasks (groups of 4 maximum)

 – High level program structure / LCD control – 24 hour timer code (based on flashing LED lab) / Include timer set control

via keypad.

 – Temperature sensor using ADC

 – Transfer time, keypad input, temperature to PC monitor via serial port

Refer to programming guidelines document in course notes, e.g., structured

 programming, flow charts, pseudo code, clear comments and label names etc

This project provides an opportunity to design & implement an embedded

system and serve as a good foundation for 3rd year and final year work.

Page 6: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 6/33

Microprocessor Systems II

Project AssignmentSubmission details :

Email zipped copy of project to [email protected]

Submit hardcopy of code (font 8) to EE departmental office

[Deadline Mon 5th

April, 5pm]Include team member names, main creator name for each code section

Include readme.txt indicating overall status and status of each sub-section

Mon 21st Feb : Assignment introductionMon 28th Feb : Lab3 completion and assessment (kpad lab) : No lecture.

All other mondays : lecture (9-11am)

Tues 8th

& 15th

Mar : lab (4-6pm, 1st

and 2nd

floor labs are available)Mon 4th Apr : (2-6pm) Demo & Assessment of project in lab

Copies of Aspire software and 8051 hardware available from Technicians

Page 7: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 7/33

g eve program structureDefine symbols etc

CSEG

ORG 0000H

JMP MAIN

tmr0 ISR :

call chkIfKPadTmrUpd ; Chk if key press instructs update of timer value, using LCD to view; field selection

restart tmr0 ; restart timer (to measure next 50ms interval)

if ticks < 19 ; 1 sec interval has not yet passedticks = ticks + 1

else ; if ticks=20 => 1 sec interval has passedticks = 0 ; clr value before restarting 1 sec delay sequencecall updateTime ; update timer (using 1 second resolution)

call readTemperature ; read temperature sensor value using ADCcall displayOnLCDLine1 ; display time and temp sensor data on LCDcall txViaUART2PC ; transmit on serial port to PC terminal

RETI ; return from ISR 

MAIN:; Initialise LCD control sigs, ADC, TMR0 (to provide 50ms interval), Serial port (for transmit to PC)

sjmp $ ; loop forever 

13:43:27 T=000

• Aids high level understanding of program structure• Similar to flowchart description

Page 8: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 8/33

Example time format (13hr:43min:27sec):1 3 : 4 3 : 2 7

sym names usedhr10 hr1 : min10 min1 : sec10 sec1

Define 6 mem locations holding these values

timeStrtAdd is addr of sec1 value

timeStrtAdd+5 is addr of hr10 valuetimStrtAdd

updateTime routine

d Ti i

Page 9: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 9/33

if sec1 < 9 thenincrement sec1

elsesec1=0if sec10 < 5 then

increment sec10else

sec10=0if min1 < 9 then

increment min1else

min1=0

if min10 < 5 thenincrement min10

else

min10=0if hr10 < 2 then ; hr10 = 0 or 1, allow hr1 values 0 -> 9

if hr1 < 9 then

increment hr1else

hr1=0increment hr10

end if 

else ; hr10 = 2, allow only hr1 values 0, 1, 2, 3

if hr1 < 3 thenincrement hr1

else ; time is 00:00:00

hr1=0hr10=0

end if 

end if end if 

end if 

end if 

updateTime routine

 pseudo code # 1Difficult to perform

‘<‘ equality check usingassembly code

Page 10: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 10/33

if sec1 = 9 thensec1=0if sec10 = 5 then

sec10=0if min1 = 9 then

min1=0if min10 = 5 then

min10=0if hr10 = 2 then ; if hr10 = 2, allow only hr1 values 0, 1, 2, 3

if hr1 = 3 then ; time => 00:00:00

hr1= 0hr10=0

else ; label hr1_LT3increment hr1

end if 

else ; label hr10_LT2 (hr10 = 0 or 1, allow hr1 values 0 -> 9)

if hr1 = 9 thenhr1=0

increment hr10

else ; label hr1_LT9

increment hr1end if 

end if else ; label min10_LT5

increment min10end if 

else ; label min1_LT9increment min1

end if else ; label sec10_LT5

increment sec10

end if 

else ; label sec1_LT9increment sec1

end if 

up a e me rou ne pseudo code # 2

Better suited to 8051 instruction set

Can perform equality checks using

CJNE A, #data, rel

INC  source :

increment value at address  source

Page 11: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 11/33

if sec1 = 9 then MOV A, sec1 CJNE A, #9, sec1_LT9

sec1=0 CLR sec1if sec10 = 5 then MOV A, sec10 CJNE A, #5, sec1_LT5

sec10=0 CLR sec10if min1 = 9 then MOV A, min1 CJNE A, #9, min1_LT9

min1=0 CLR min1if min10 = 5 then MOV A, min10 CJNE A, #5, min10_LT5

min10=0 CLR min10if hr10 = 2 then ; if hr10 = 2, allow only hr1 values 0, 1, 2, 3 MOV A, hr10 CJNE A, #2, hr10_LT2

if hr1 = 3 then ; time => 00:00:00 MOV A, hr1 CJNE A, #3, hr1_LT3

hr1= 0 CLR hr1

hr10=0 CLR hr10else hr1_LT3:

increment hr1 INC hr1

end if 

else ; (hr10 = 0 or 1, allow hr1 values 0 -> 9) hr10_LT2:

if hr1 = 9 then MOV A, hr1 CJNE A, #9, hr1_LT9

hr1=0 CLR hr1increment hr10 INC hr10

else hr1_LT9:

increment hr1 INC hr1end if 

end if else min10_LT5:

increment min10 INC min10end if 

else min1_LT9:increment min1 INC min1

end if else sec10_LT5:

increment sec10 INC sec10end if 

else sec1_LT9:increment sec1 INC sec1

end if 

uccess ve pprox ma on opera on

Page 12: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 12/33

enlk

clk 

Analogue input

signal(range 0 -> Vref)

12-bit digital

output signal

(parallel form),ADCDATAH(3:

ADCDATAL(7:

uccessive Approx

egister (SAR), [counter]

• SAR inputs bit pattern to DAC to generate an analogue voltage to compare with analogueinput signal.

• SAR monitors comparator’s o/p, checking if analogue i/p is greater or less that VinAdjusts DAC input bit values accordingly

• SAR adjusts DAC input bit pattern to find DAC ouput which is closest to Vin

• First, SAR asserts DAC input bits in turn (8 in this illustration), starting with MSB to findrequired MSB asserted bit

• SAR counting strategy results in a fast solution; DAC binary output quickly converges onthe analogue signal input

comparator 

uccess ve pprox ma on opera on

strtConv

(only 8 bitsillustrated

here)

AD C831 ADC Operation

Page 13: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 13/33

ADuC831 ADC Operation (pp 18-24 of spec)

• ADuC831 incorporates fast 8-channel 12-bit single supply ADC

• Conventional successive approximation converter based around capacitor DAC

• Reliable, accurate and fast

• Accepts analogue i/p voltage range 0 -> Vref 

• If input changes during conversion, error is no greater than the change during conversion• Multiple steps are required to convert input signal

• I/P signals :

clk VinstrtConv : start of conversion

• O/P signals :endConv (end of conversion )12-bit digital parallel o/p

ADCDATH(3:0), ADCDATAL(7:0)

ADC Operation

Page 14: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 14/33

ADC Operation

• ADC input : on-chip temperature sensor : voltage proportional to absolutetemperature

• Use on-chip reference voltage [Vref = 2.5V] (defines max sampled input voltage

• 12-bit ADC resolution :2.5V/4096 = 0.61mV01h represents 0.61mV, 0FFFh represents 2.5V

• ADC configured via 3 register SFR interface (ADCCON1, ADCCON2, ADCCON3)

• Single step ADC conversionTrigger ADC (every one second) & write value to defined memory locationdefined tempAdd as address of temperature value

• Refer to sample .asm files in C:\ADuC\Code\831\ADC

ADCCON1 bit settings

Page 15: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 15/33

ADCCON1 bit settings

• ADCCON1 (7) 1 : powerup ADC

(6) 0 : internal reference voltage

(5:4) 00 : divide ratio = 16 for master clock If using temp sensor, ADC should be configured to use an

ADCCLK of MCLK/16 (and 4 acquisition clocks)

(3:2) 11 : ADC acquisition select bits

If using temp sensor, ADC should be configured to use an

4 acquisition clocks

(1) 0 : tmr2 o/flow not used to trigger ADC conversion

(0) 0 : p3.5 external ADC trigger input not used

ADCCON2 bit tti

Page 16: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 16/33

• ADCCON2 (7) - : ADC interrupt bit, set by h/w at end of ADC conversion cyc

 Not using ADC interrupts in this course. Defaults to disabled

(6) 0 : DMA mode enable bit

(5) 0 : Continuous conversion bit

(4) 1 : Single conversion bit, set to initiate a single conversion cyc

Automatically reset to 0 on completion of single conv cyc

Assert (bit addressable) to start ADC conversion

(3:0) 1000 : Channel selection bits, 1000 => temperature monitor 

ADCCON2 bit settings

ADCCON3 bit settings

Page 17: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 17/33

• ADCCON3 (7) - : ADC busy status bit (read only)

Suggest poll of ADCCON3(7) to detect conversion complete

(6) 0 : gain calibration disable

(5:4) 00 : number of averages selection bits

(3:0) 0100 : ADC calibration bits (see data sheet)

Total ADC conversion time is 15 ADC clks plus 1 ADC clock for synchronisation,plus the selected ADC acquisition time (4 ADC clocks when using the temp sensor)

ADCCON3 bit settings

ADC Functionality not used in this course

Page 18: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 18/33

ADC Functionality not used in this course

• Continuous ADC conversion, external trigger conversion etc

• Continuous ADC conversion & capture samples to external RAM space (withoutinteraction of MCU core)

• Offset and gain calibration

• ADC DMA Mode

rea emperature rout ne

Page 19: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 19/33

rea emperature rout ne

Refer to ADC section in ADuC831 data sheet (pp 18-24)

Also, refer to C:\ADuC\Code\831\ADC\ADCsingl.asm :

Performs repeated single ADC conversions and moves results to P0 & P2.Sets the red LED on the eval board upon completion of each conversion.

A new conversion is initiated every 200ms

All rate calculations assume an 11.0592MHz Mclk 

Some changes are required since accessing the temperature sensor ADC channel

c a mr p rout ne

Page 20: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 20/33

c a mr p rout neStore timeStrtAdd in R0 ; store pointer to start mem location of 24 hr time values, will use later 

If keypadPressed then

if keyA pressed then set updFlg (bit). Default setting is clear (0)

if updFlg set thenif keyB pressed then ; select field for update

if tmrFieldIndex = 0 then

tmrFieldIndex=5 ; hr10 field is selected for updateelse

decrement tmrFieldIndex ; select hr1(4), min10(3), min1(2), sec10(1), sec1(0)end if 

elsif keyC pressed then increment value in address R0+tmrFieldIndexelsif keyD pressed then decrement value in address R0+tmrFieldIndex

elsif keyE pressed then clr updFlg

end if 

end if 

Timer control (using keypad keys A, B, C, D, E) :

A: Update time mode (ON/OFF)B: toggle time field (Hr10 -> Sec1)C: increment selected time fieldD: decrement selected time field

E: apply changes and return to normal operation

sp ay n ne rout ne

Page 21: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 21/33

sp ay n ne rout neDisplay format :

Time and temperature

If updFlg asserted, position flashing cursor at appropriate field

Refer to LCD instruction set

13:43:27 T=000

onvers ons a e

Page 22: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 22/33

onvers ons a eTo convert from BCD (time vlaues) to ASCII, add 30hex (48d)

Other examples : line feed #10 (decimal), Carriage return is ASCII 13 (decimal)

Serial Port References

Page 23: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 23/33

Serial Port Referenceshttp://www.ctips.com/rs232.html

http://computer.howstuffworks.com/serial-port.htm

Microconverter data sheet (ADuC831.pdf ) UART Serial interface, pp 55-58

Use 9600 baud rate for 11.0592MHz clk 8031 and preconfigured 9600 baud hyperterminal program provided by C:\ADuC\9600com1.ht

C:\ADuC\Code\831\UART\UART1.asmDescription : saves 16 numbers in order initially, starting with 0, into memory locations 40h to 50h.

When finished, the values in these locations are transmitted down the UART in ASCII form to the PC

where they can be viewed using the preconfigured hyperterminal program (c:\ADuC_Beta832\9600com1.ht).

After the transmission of the 16 bytes, a 5 second delay is called and the process is repeated

C:\ADuC\Code\831\UART\UARTIO.asm for standard UART I/O subroutinesSENDSTRING - sends a string of characters SENDCHAR - sends a single character  

SENDVAL - sends a byte as 2 ASCII characters HEX2ASCII - converts from HEX to ASCII

ASCII2HEX - converts from ASCII to HEX GETCHAR - gets a single character;GETVAL - gets a byte as 2 ASCII characters

Serial Port Operation

Page 24: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 24/33

Serial Port OperationSerial ports provide standard connector & protocol to support attaching of devices,

such as modems, to an embedded system.Serial port transmits byte of data one bit at a time

Adv : requires only one wire to transmit data (lower cable costs, smaller cables)

Disadv : takes minimum 8 times as long to transmit dataFull duplex : rx & tx processing at the same time

Serial communications method is known as asynchronous communication becau

sending & receiving ends of the communication are not precisely synchronisedusing a synchronising signal line (e.g., clk)

Serial port uses UART (Universal Asynchronous Receiver Transmitter) device

Transmit Start bit & LSB first8031 signal interface :RxD (P3.0), TxD (P3.1)

rx buffer enables buffering received

TxD

RxD

PC UA8031 UART

rx buffer 

erial port operation : synchronisation

Page 25: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 25/33

erial port operation : synchronisationMarkers added to help track each data bit

Single ‘0’ start bit transmitted before each byte of dataTwo systems don't require synchronising clock signal

Both systems must be set at the same port speed/baud rate, e.g., 9600 baud

Definition : speed of info being transmitted across serial interface (bits/sec (bps))8-bit ASCII character plus start bit plus one stop bit (total 10 bits) at 9600 baudwould be transmitted in 10/9600 sec. = 1.042 ms or about 960 characters/sec.

When receive UART receives start bit, it starts a short term timer.

By keeping streams short, there's not enough time for the timer to get out of sync

Stop bit (optional parity bit and second stop bit) transmitted after each byte of data

Transmit Start bit & LSB first8031 signal interface :RxD (P3.0), TxD (P3.1)

TxD

RxD

PC UA8031 UART

rx buffer 

Serial port operation : synchronisatio

Page 26: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 26/33

Example asynch serial data packet transfer using 8 bit word, even parity, 1 stop bit

Course assignment uses asynch serial data packet transfer using

8 bit word, no parity, 1 stop bit

8051 UART samples 16 times / bit (timer overflows 16 times before bit istransmitted or received)

Serial port operation : synchronisatio

Central sample

points

(mid point of 16

samples per bit)

Additional Serial port signals

Page 27: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 27/33

Additional Serial port signalsTransmit Data (TxD) – serial transmit data

Receive Data (RxD) – serial receive data

Serial port flow control is provided by the following signals (not required inassignment application)

Carrier Detect (CD) determines if modem connected to working phone line

Data Terminal Ready (DTR) embedded system available for communication

Data Set Ready (DSR) destination device available for communication

Request To Send (RTS) embedded system requests authorisation to send data

Clear To Send (CTS) destination device acknowledges embedded system that datacan be sent

Ring Indicator (RI) when call has been placed (to modem), embedded systemacknowledges signal (sent from modem) that a ring is detecte

Used in formal assignment

Serial port operation : synchronisatio

Page 28: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 28/33

Baud rate set by TMR1, TMR2 or TMR3 overflow rate

Can have define separate tx & rx baud rates

Baud rates up to 460kbps supported by some UARTS

Transmit Start bit & LSB first

TxD

RxD

PC UA8031 UART

rx buffer 

Serial port operation : synchronisatio

Serial Port Baud Rate using TMR3

Page 29: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 29/33

Serial Port Baud Rate using TMR3Use 9600 baud rate for 11.0592MHz clk 8031 and preconfigured 9600 baud

hyperterminal program provided by C:\ADuC\9600com1.ht

TMR3 can be used for generating very accurate high speed baud rates & free upother timers for other uses

T3CON & T3FD register settings :

T3CON(7) = 1 enables baud rate generation using timer 3

T3CON(6:3) are don’t careT3CON(2:0) = 101

and T3FD (fractional divider ratio to generate required baud rate) = 08h

Table XXVII extract

Page 30: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 30/33

er a port transm t on y : sett ng

Page 31: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 31/33

er a port transm t on y : sett ngSCON (98h), bit addressable. Program Value = 42h

(7:6) 01 => 8-bit UART mode, variable baud rate

(5) 0 => byte received

(4) 0 => enable serial port reception

(3:2) 00

(1) 1 => TI flag, default ‘1’, Serial port TX interrupt flag. Set by hardware

when previous byte transmission complete

Must be cleared by s/w before performing new transmit

(0) 0 => Serial port RX interrupt flag, set on completion of byte receipt

Must be cleared by s/w

SBUF (SFR address 99h)

write TxD data : write to SBUF initiates new tx (this loads ‘1’ stop bit into

transmit shift reg bit 9)

Data is o/p bit-by-bit until stop bit appears on TxD and TI is automatically set

er a port x x : sett ngs

Page 32: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 32/33

e a po : se gsSCON (98h), bit addressable. Program Value = 52h

(7:6) 01 => 8-bit UART mode, variable baud rate

(5) 0 => RIflag assertion indicates byte received (note error in ADuC831.pdf 

table XXIII, SM2 description

(4) 1 => enable serial port reception

(3:2) 00(1) 1 => TI flag, default ‘1’, Serial port TX interrupt flag. Set by hardware

when previous byte transmission complete

Must be cleared by s/w before performing new transmit

(0) 0 => Serial port RX interrupt flag, set on completion of byte receiptMust be cleared by s/w

SBUF (SFR address 99h)

write TxD data : serial transmission occurs automaticallyread SBUF : reads receive register contents

Serial port receive operation

Page 33: Microprocessor%20Systems%20II%20Project

8/7/2019 Microprocessor%20Systems%20II%20Project

http://slidepdf.com/reader/full/microprocessor20systems20ii20project 33/33

p pFor Mode 1 operation (SCON(7:6)=01) :

Receive operation initiated when 1->0 transition detected on RxD.

If start bit valid, 8 following characters are registered into serial port shift reg(SBUF)

If SCON(7:6) = 01, Receive Interrupt (RI) = 0 and stop bit received, then :data is placed in SBUF & RI is asserted

Otherwise frame is lost & RI is not asserted.

TxD

RxD

PC UART8031 UART

rx buffer