Professional Documents
Culture Documents
RS-232protocol:
Serial asynchronous Full duplex protocol
High Mark
Low(space) Undefined Simplest in terms of programming Available in most microcontrollers (in built UART)
-12V to -3V
+12V to +3V +3V to -3V
Time
Time
Timing Diagram
Below is a timing diagram for the transmission of a single byte Uses a single wire for transmission Each block represents a bit that can be a mark(logic 1) or space(logic 0)
mark
space
Time
The start bit marks the beginning of a new word When detected, the receiver synchronizes with the new data stream
Start
Next follows the data bits(5,6,7,8 or 9) The least significant bit (LSB) is sent first 8 Data bits LSB MSB
The parity bit is added to make the number of 1s even (even parity) or odd (odd parity) This bit can be used by the receiver to check for transmission errors Use of parity bits is optional Parity Bit
The stop bit marks the end of transmission Receiver checks to make sure it is 1 Separates one word from the start bit of the next word You can send 2 stop bits also Stop Bit
Stop Bit
Stop bit defines the number of stop bits implemented in the transmitter
This parameter can be set to 1(default) or 2data bits
Word is given to the UART for asynchronous transmission Start Bit is added to the beginning of the word START BIT is added to alert the receiver about sending of the word
It also forces the clock in the receiver into synchronization with the clock in the transmitter
These clocks must be accurate enough to not have the frequency drift by more than 10% Once after sending start Bit , the individual bits of the word of data are send, with LSB first When receiver has received all of the bit in the data word, it may check for the Parity Bits Then receiver looks for a Stop Bit
If the Stop Bit does not appear then the UART considers the entire word to be garbled and will report a Framing Error to the host processor when the data word is read. The usual cause of a Framing Error is that the sender and receiver clocks were not running at the same speed, or that the signal is interrupted.
Transmission Requirement
Before transmission begins, transmitter and receiver must agree on: Baud rate (300,600,etc)
Approaches
Approaches
Polling
Polling Flowchart :
Start
Initialize
Service Device N
CPU keeps on checking periodically if an event which is desired has occurred Occurrence of event is generally signaled by setting a flag
Advantages:
Simple Knowledge of interrupt priorities not required
Predictable behavior
Disadvantages:
Eats up CPU time
If there are too many services/devices to be polled ,responsiveness will decrease
Initialize
Service Interrupt
Advantages:
CPU is free for majority of the time
Responsiveness is better as compared to polling based approach
Disadvantages:
Software implementation is complex Nested interrupts can lead to stack over flow(RTOS)
Data need not to be continuous or may be burst data but is transmitted at fixed rate Data is send byte by byte