Micro Unit 6 Question Anser Notes
Micro Unit 6 Question Anser Notes
The specification allows for data transmission from one transmitter to one receiver at
relatively slow data rates (up to 20K bits/second) and short distances (up to 50Ft. @ the
maximum data rate).
IN RS232 communication, the transmitting device is the DTE such as a computer, and the
receiving device is the DCE such as a printer.
Logic „0‟=+3v to +5 v
Logic „1‟=-3v to -5 v
The RS232 signals are represented by voltage levels with respect to a system common that is
ground; this is called single ended communication.
RS-232 Standard Cabling
RS 485 Protocol
The Electronics Industry Association (EIA) has produced standards RS485, which deal with
data communications.
RS-485 allows multiple devices (up to 32) to communicate at half-duplex on a single pair of
wires, plus a ground wire at distances up to 1200 meters (4000 feet).
Both the length of the network and the number of nodes can easily be extended using a
variety of repeater.
The RS-485 standard uses differential signaling on two lines rather than single-ended with a
voltage referenced to ground
Differential data transmission allows longer cables(hundreds of meters) and Allows higher
speeds (in Mbps)
In a "two-wire" network the transmitter and receiver of each device are connected to a
twisted pair.
12. The RS-485 interfaces is widely used in industrial applications where higher speeds and
longer distances are needed.
1. SPI was first introduced by Motorola in 1979. SPI defined the external microcontroller bus,
used to connect the microcontroller peripherals with 4 wires.
2. SPI Bus is a way to communicate between 2 digital devices.
3. Both SPI and I2C protocols are well-suited for communications between integrated circuits,
for slow communication with on-board peripherals
Protocol
1. SPI is a protocol on 4 signal lines
A clock signal named SCLK, sent from the bus master to all slaves; all the SPI signals are
synchronous to this clock signal;
A slave select signal for each slave, SSn,or CS(chip select) used to select the slave the
master communicates with;
A data line from the master to the slaves, named MOSI (Master Out-Slave In)
A data line from the slaves to the master, named MISO (Master In-Slave Out).
2. SPI is a single-master communication protocol. This means that one central device initiates
all the communications with the slaves.
3. When the SPI master wishes to send data to a slave and/or request information from it, it
selects slave by pulling the corresponding SS line low and it activates the clock signal at a clock
frequency usable by the master and the slave.
4. SPI provides full duplex communication using these two data lines MISO and MOSI
Protocol
1. I²C is a multi-master protocol that uses 2 signal lines.
2. The two I²C signals are called „serial data‟ (SDA) and „serial clock‟ (SCL). There is no need
of chip select (slave select) or arbitration logic.
3. Virtually any number of slaves and any number of masters can be connected onto these 2
signal lines and communicate between each other using a protocol that defines:
7-bits slave addresses: each device connected to the bus has got such a unique
address, 2^7 =128 devices can communicate.
In extended I2C 10 bit addressing (up to 2^10 =1024 addresses)
data divided into 8-bit bytes
4. Physically, the I²C bus consists of the 2 active wires SDA and SCL and a ground connection.
5. The active wires are both bi-directional.
6. Sequence of write operation by I2C bus protocol is as follows,
SPI I2C
Three bus lines are required; a data input Two bus lines are required; a serial
line (SI), a data output line (SO) and a data line (SDA) and a serial clock line
serial clock line (SCK) [plus 1 Chip (SCL)
Select (CS)]
Support transfer speeds of around 100
Higher data rates (up to 10 MHz or kHz (original standard, or 400 kHz
more), More speed. using the most recent standard) less
speed.
Full Duplex communication
Half Duplex communication
More efficient in point-to-point (single
master, single slave) applications More efficient in multi-master, multi-
slave applications
Lack of built-in device addressing,
Device can be selected using CS signal Built-in addressing scheme.
Device can be selected with its unique
address.
No of devices can be increased with
more no of cs/ss signals, more hardware. No of devices can be increased without
adding extra hardware
Does not have an acknowledgement
mechanism to confirm receipt of data Have an acknowledgement mechanism
to confirm receipt of data.
Architecture
Architecture
Q 6.Elobrate MSSP (Master Synchronous Serial Port) Module of PIC
MSSP is used for communicating the PIC microcontroller with the different peripheral
devices like ADC, DAC ,EEPROM, RTC , Display Drivers, SD Cards , Temperature
Sensor, USB devices
I2C mode
SPI mode
The SPI mode allows 8 bits of data to be The MSSP module in the I2C mode fully
synchronously transmitted and received implements all master and slave functions
simultaneously. Both 7-bit and 10-bit addressing are
To accomplish communication, typically supported.
three pins are used: Two pins are used for data transfer:
Serial Data Out (SDO) – RC5/SDO Serial clock (SCL)-RC3/SCK/SCL
Serial Data In (SDI) –RC4/SDI/SDA Serial data (SDA)-RC4/SDI/SDA
Serial Clock (SCK) – RC3/SCK/SCL
Select (SS) – RA5/AN4/SS/LVDIN
PIC Microcontroller performs serial communications using USART. It has two pins for serial
communication TX and RX
The PIC18 transmit & receive data serially at different baud rates.
The baud rate in PIC18 is programmable.
This is done with 8-bit register called as SPBRG.
For given crystal frequency, the value loaded into the SPBRG decides the baud rate.
UsingAbove formula if we calculate baud rate the value we are getting for SPBRG are given in
below table
The DS1307 is Serial Real-Time Clock IC. It is a low-power; full binary-coded decimal (BCD) clock/calendar
Address and data are transferred serially via a 2-wire, bi-directional bus. The clock/calendar provides seconds,
minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for
months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or
12-hour format with AM/PM indicator
Interfacing Diagram:
REGISTERS For I2C Operation
The MSSPmodule has six registers for I2C operation
MSSP Control Register 1 (SSPCON1)
MSSP Control Register 2 (SSPCON2)
MSSP Status Register (SSPSTAT)
Serial Receive/Transmit Buffer (SSPBUF)
MSSPShift Register (SSPSR)
MSSP Address Register (SSPADD)
We now want to Read, write and Erase EEPROM by using SPI in PIC18F Board.
The basic operation of the SPI based EEPROM's is to send a command, such as WRITE, followed by an
address and the data.
In WRITE operation, the EEPROM to store the data. In SPI, the clock signal is controlled by the master
device PIC18F Board.
All data is clocked in and out using this pin.
The EEPROM read & write operations are done in PIC18F Kit by using these CS, CLK, MOSI, MISO
SPI lines
The Read & Write operations are performed in EEPROM with EEPROM address. When the EEPROM
address is correct, then only you can write, read, and erase data‟s correctly in EEPROM.
Algorithm for Program
We use following SPI COMMANDS
#define READ 0x03
#define WRITE 0x02
#define WRDI 0x04
#define WREN 0x06
#define RDSR 0x05
#define WRSR 0x01
We would create these functions:
void Serial_init(void);
void SPi_init(void);
void SPi_WRITE(unsigned char);
unsigned char SPi_RDSR(void);
unsigned char SPi_READ(unsigned char);
void DelayMs(unsigned int);
A typical example application is controlling traffic lights. We chose to design and build a
basic traffic signal for four tracks traffic intersection, three signals per track, green,
yellow and red.
Using microcontroller PIC18F 4550 to get outputs in a specific times according to the
data specified in the program, which will be drive twelve LEDs that represent the
different signals for each track.
The objective is, to design and implement a traffic light control. This traffic light
controller is used at the intersection that consists of main road and two side roads.
The system is to be developed with the PIC18F4550 chip being the microcontroller that
is programmed
The drawback is that it does not take into account variables such as cars wanting to turn
left or pedestrians pressing a crossing button.
Interfacing Diagram:
LED Connection
The red LED indicates “stop driving”, the yellow LED indicates “start stopping” and the
green LED indicates “drive”.
The sequence of altering the LEDs according to their color is as below:
Green-Yellow-Red-Green.