Serial Port Complete - Latest Microcontroller projects

(lily) #1

Chapter 11


else
' For other characters, send back the same character.

serial_out = serial_in
endif

' Set a variable to indicate that a byte is ready for transmitting.

data_ready_to_send = 1
endif
return
This routine checks the data_ready_to_send variable, which indicates whether
serial_out contains a byte to be sent on the serial port. If data_ready_to_send =
1 and flow_control_input = 0, the routine sends the byte and sets
flow_control_output = 1 to enable receiving another byte.
transmit_serial_data:

if (data_ready_to_send = 1) then

' A byte is ready to send on the serial port.

if (flow_control_input = 0) then

' The flow control input is asserted.
' Reset the variable that indicates a byte is ready to send
' and send the byte.

data_ready_to_send = 0
hserout [serial_out]

' Tell the remote computer it’s OK to send more data.

flow_control_output = 0
endif
endif
return
Free download pdf