You are on page 1of 33

Quaid -E- Awam University of Engineering, Science and

Technology Nawabshah

#8

EMBEDDED SYSTEMS

Department of Computer Systems Engineering


PIC microcontroller
Peripheral interface controller (PIC)

 Microcontroller integrate all the components


of a computer system onto a single chip.
 Size, cost, capability and power consumption
are more important.
 8-bit , 16-bit and 32-bit PIC microcontroller
are used to design embedded systems.
 PIC microcontroller was originally designed
around 1980 by General Instrument as a
small, fast, inexpensive embedded systems.
PIC microcontroller

 Range of 8 bit microcontrollers.


 Smallest 8 pins.
 largest 40 pins.
 Typical chip has 18 pins.
 Very cheap.
 It is a RISC design, Instructions are
programmed in flash memory
 Only thirty seven instructions.
 Its code is extremely efficient, allowing the
PIC to run with typically less program
memory.
PIC architecture (Harvard)
PIC architecture (Harvard)
PIC- CPU
PIC-CPU
PIC (Architecture)
PIC –Architecture: Load/store

 A load/store architecture typically means that operands to ALU


operations have to be in registers, so that you have to load them
from memory before and store them back when operations are
complete.
 The opposite typically allows operations between a register or
accumulator and a memory location directly.
 RISC architectures uses load/store.
PIC –Architecture: Accumulator

 In an “accumulator based” architecture, there is usually one


“special” register where most of the actual computation occurs.
Some effort has to be spent to get operands into the
accumulator and results back out to where you need them. The
opposite is a processor with “general purpose” registers, where
any of several registers can be used for math.
Memory space
Memory address space
DATA MEMORY
PIC MEMORY
PIC architecture
Processor Unit
ALU
ALU operation
PIC registers
Instructions
Logical instructions
PIC-architecture (SPI)

Serial Peripheral Interface (SPI)


 Is a synchronous serial communication interface used for short-distance
communication in embedded systems.
 Communicates in full duplex mode using a master-slave architecture.
 The master (controller) device originates the frame for reading and
writing.
 Multiple slave-devices may be supported through selection with
individual chip select (CS), sometimes called slave select (SS) lines.

SCLK: Serial Clock (output from master)


MOSI: Master Out Slave In (data output from master)
MISO: Master In Slave Out (data output from slave)
CS /SS: Chip/Slave Select (often active low, output from master to
indicate that data is being sent)
PIC-architecture (UART)

Universal Asynchronous Receiver and Transmitter


 Asynchronous data transfer, there is no clock signal for transmission and reception
 is a computer hardware device for asynchronous serial communication in which
the data format and transmission speeds are configurable.
 It sends data bits one by one, from the least significant to the most significant,
framed by start and stop bits so that precise timing is handled by the
communication channel.
 Signal levels RS-232 standard are used for the serial transmission of data.
 One or more UART/USART peripherals are commonly integrated in microcontroller
chips.
PIC-architecture (UART-start bit)

Universal Asynchronous Receiver and Transmitter


Example of 8-bit transmission:
The TXREG register acts as a temporary buffer storage of information prior to
transmission.
The bit TX9 will be zero (TX9=0) - which determines that the transmission will be
8-bit transmission, so there is no need to address TX9D bit, which stores the
ninth bit of information.
PIC-architecture (UART-stop bit)

Universal Asynchronous Receiver and Transmitter


Example of 8-bit transmission:
 Receiver side receive 8 bit information.
 The received information will be stored in the RSR register, which acts as a
temporary buffer storage.
 Register RX9 will be zero (RX9=0).
PIC-architecture (USART)

Universal Asynchronous Synchronous Receiver and Transmitter


When using the synchronous communication – the information is transmitted from
the transmitter to the receiver:
 in sequence
 bit after bit
 with fixed baud rate
 and the clock frequency is transmitted along with the bits
That means that the transmitter and the receiver are synchronized between them
by the same clock frequency. The clock frequency can be transmitted along with the
information, while it is encoded in the information itself, or in many cases there is
an additional wire for the clock.
This type of communication is faster compare to the asynchronous
communication since it is "constantly transmitting” the information, with no stops.
PIC-architecture (TWI /I2C)

TWO WIRE INTERFACE / INTER INTEGRATED CIRCUIT


 I2C communication was first introduced by Phillips. As said earlier it
has two wires, these two wires will be connected across two devices.
Here one device is called a master and the other device is called
as slave. Communication should and will always occur between two
a Master and a Slave. The advantage of I2C communication is that
more than one slave can be connected to a Master.
 I2C is a synchronous communication protocol meaning, both the
devices that are sharing the information must share a common clock
signal.

The complete communication takes


place through these two Serial Clock
(SCL): Shares the clock signal generated
by the master with the slave
Serial Data (SDA): Sends the data to and
from between the Master and slave.
PIC-architecture (TWI /I2C)

TWO WIRE INTERFACE / INTER INTEGRATED CIRCUIT


 I2C communication is used only for short distance communication.
 RS232 serial communication is used for a long range communication.
 For more reliable communication SPI protocol is used.
PIC-architecture (I/O PORTS)

FIVE I/O PORTS


 The role of the PORT register is to receive the information from an
external source or to send information to the external elements.
 The default mode of each TRIS is input.
PORTA is a 6-bit wide, bidirectional port. The corresponding data
direction register is TRISA.
Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input.
Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an
output.
PORTB is an 8-bit wide, bidirectional port. The corresponding data
direction register is TRISB.
PORTC is an 8-bit wide, bidirectional port. The corresponding data
direction register is TRISC.
PORTD is an 8-bit port used as input buffers. Each pin is individually
configurable as an input or output.
PORTE has three pins (RE0/RD/AN5, RE1/WR/AN6 and RE2/CS/AN7)
which are individually configurable as inputs or outputs.
Addressing Modes
I/O PORTS
Allah Hafiz

You might also like