0% found this document useful (0 votes)
20 views27 pages

CEN 389 Week 4

The document discusses embedded systems focusing on hardware design, communication interfaces, and analog-to-digital converters (ADCs). It details onboard and external communication interfaces, including UART, I2C, and SPI protocols, as well as the importance of ADCs in converting analog signals for microcontroller processing. Additionally, it provides examples of configurations and usage of ADCs in PIC microcontrollers.

Uploaded by

‘‘
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views27 pages

CEN 389 Week 4

The document discusses embedded systems focusing on hardware design, communication interfaces, and analog-to-digital converters (ADCs). It details onboard and external communication interfaces, including UART, I2C, and SPI protocols, as well as the importance of ADCs in converting analog signals for microcontroller processing. Additionally, it provides examples of configurations and usage of ADCs in PIC microcontrollers.

Uploaded by

‘‘
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

CEN 389 EMBEDDED SYSTEMS

Week 4
TOPICS TO BE DISCUSSED
• Hardware Design
• Serial Interfaces / Communication Interface
• Analog Digital Converters

2
Serial Interfaces / Communication Interface
Communication interface is essential for communicating with various subsystems of
the embedded system and with the external world.

The communication interface can be viewed in two different perspectives; namely;

1. Device/board level communication interface (Onboard Communication Interface)

2. Product level communication interface (External Communication Interface)


1. Device/board level communication interface (Onboard
Communication Interface)
• The communication channel which interconnects the various
components within an embedded product is referred as Device/board
level communication interface (Onboard Communication Interface)

➢ Examples: Serial interfaces like I2C, SPI, UART, 1-Wire etc and Parallel
bus interface
2. Product level communication interface (External
Communication Interface)
• The ‘’Product level communication interface’’ (External
Communication Interface) is responsible for data transfer between
the embedded system and other devices or modules. The external
communication interface can be either wired media or wireless media
and it can be a serial or parallel interface.
➢ Examples for wireless communication interface: Infrared (IR),
Bluetooth (BT), Wireless LAN (Wi-Fi), Radio Frequency waves (RF),
GPRS etc.
➢ Examples for wired interfaces: RS-232C/RS-422/RS 485, USB, Ethernet
(TCP-IP), IEEE 1394 port, Parallel port etc.
2. Product level communication interface (External
Communication Interface)
1. Device/board level communication interface (Onboard
Communication Interface)
• The communication channel which interconnects the various
components within an embedded product is referred as Device/board
level communication interface (Onboard Communication Interface)
• PIC microcontroller offers a choice of serial interfaces. The best one
for any given communication channel depends on the distance
between nodes, the speed, and the number of hardware connections
required.
1. UART (Universal Asynchronous Receiver Transmitter)
2. I2C (Inter Integrated Circuit) Bus
3. SPI (Serial Peripheral Interface) Bus
UART (Universal Asynchronous Receiver Transmitter)
• The universal synchronous/asynchronous receive transmit (USART)
device is typically used in asynchronous mode to implement off-
board, one-to-one connections.

• The term asynchronous means no separate clock signal is needed to


time the data reception, so only a data send, data receive, and ground
wires are needed. It is quick and simple to implement if a limited data
bandwidth is acceptable.
UART (Universal Asynchronous Receiver Transmitter)
• A common application is connecting the PIC chip to a host PC for
uploading data acquired by the MCU subsystem. The USART link can
send data up to 100 meters by converting the signal to higher-voltage
levels (typically 12 V). The digital signal is inverted and shifted to
become bipolar (symmetrical about 0 V, line negative when inactive)
for transmission.
UART (Universal Asynchronous Receiver Transmitter)
• The PIC 16F877 has a dedicated hardware RS232 port, but CCS C allows any pin to
be set up as an RS232 port, providing functions to generate the signals in
software. The basic form of the signal has 8 data bits and a stop and start bit.
• The bit period is set by the baud rate. A typical value is 9600 baud, which is about
10 k bits per second. The bit period is then about 100 μ s, about 1 byte per
millisecond, or 1 K byte per second.
• The data are transferred between shift registers operating at the same bit rate;
the receiver has to be initialized to the same baud setting as the transmitter.
Assuming we are looking at TTL level data, in the idle state, the line is high. When
it goes low, the receiver clock is started, the data are sampled in the middle of
each following data bit period, and data are shifted into the receive register.
I2C (Inter Integrated Circuit) Bus
• The inter integrated circuit (I 2 C) bus is designed for short-range
communication between chips in the same system using a software
addressing system. It requires only two signal wires and operates like
a simplified local area network. The basic form of the hardware and
data signal are illustrated in
I2C (Inter Integrated Circuit) Bus
• SCL line is responsible for generating synchronization clock pulses and SDA
is responsible for transmitting the serial data across devices.I2C bus is a
shared bus system to which many number of I2C devices can be connected.
Devices connected to the I2C bus can act as either „Master‟ device or
„Slave‟ device.
• The „Master‟ device is responsible for controlling the communication by
initiating/terminating data transfer, sending data and generating necessary
synchronization clock pulses.
• Slave devices wait for the commands from the master and respond upon
receiving the commands. Master and „Slave‟ devices can act as either
transmitter or receiver. Regardless whether a master is acting as
transmitter or receiver, the synchronization clock signal is generated by the
„Master‟ device only.I2C supports multi masters on the same bus.
I2C (Inter Integrated Circuit) Bus
1. Master device pulls the clock line (SCL) of the bus to „HIGH‟
2. Master device pulls the data line (SDA) „LOW‟, when the SCL line is at logic
„HIGH‟ (This is the „Start‟ condition for data transfer)
3. Master sends the address (7 bit or 10 bit wide) of the „Slave‟ device to which it
wants to communicate, over the SDA line.
4. Clock pulses are generated at the SCL line for synchronizing the bit reception by
the slave device.
5. The MSB of the data is always transmitted first.
6. The data in the bus is valid during the „HIGH‟ period of the clock signal
7. In normal data transfer, the data line only changes state when the clock is low.
I2C (Inter Integrated Circuit) Bus
9. Slave devices connected to the bus compares the address received with the address
assigned to them
10. The Slave device with the address requested by the master device responds by sending
an acknowledge bit (Bit value =1) over the SDA line
11. Upon receiving the acknowledge bit, master sends the 8bit data to the slave device over
SDA line, if the requested operation is „Write to device‟.
12. If the requested operation is „Read from device‟, the slave device sends data to the
master over the SDA line.
13. Master waits for the acknowledgement bit from the device upon byte transfer complete
for a write operation and sends an acknowledge bit to the slave device for a read operation
14. Master terminates the transfer by pulling the SDA line „HIGH‟ when the clock line SCL is
at logic „HIGH‟ (Indicating the „STOP‟ condition).
I2C (Inter Integrated Circuit) Bus
SPI (Serial Peripheral Interface) Bus
The serial peripheral interface (SPI) bus provides high-speed
synchronous data exchange over relatively short distances (typically
within a set of connected boards), using a master/slave system with
hardware slave selection. One processor must act as a master,
generating the clock. Others act as slaves, using the master clock for
timing the data send and receive. The slaves can be other
microcontrollers or peripherals with an SPI interface. The SPI signals are
● Serial Clock (SCK)
● Serial Data In (SDI) (Master Out Slave In (MOSI))
● Serial Data Out (SDO) (Master In Slave Out (MISO))
● Slave Select (!SS)
SPI (Serial Peripheral Interface) Bus
• Master Out Slave In (MOSI): Signal line carrying the data from master to slave
device. It is also known as Slave Input/Slave Data In (SI/SDI)
• Master In Slave Out (MISO): Signal line carrying the data from slave to master
device. It is also known as Slave Output (SO/SDO)
• Serial Clock (SCLK): Signal line carrying the clock signals
• Slave Select (SS): Signal line for slave device select. It is an active low signal.
SPI (Serial Peripheral Interface) Bus
• To transfer data, the master selects a slave device to talk to, by
taking its SS line low. Eight data bits are then clocked in or out of
the slave SPI shift register to or from the master.
Analog Digital Converters
• All systems naturally found in nature are in analog order.
• The microcontrollers are digital systems.
• In order to communicate with the outside world and receive data from the outside
world, these two systems must somehow understand each other.
• For this, it is necessary to convert analog signals into digital signals that digital
systems can understand.
Analog Digital Converters
• ADC circuits and ICs are used for this process. The number of bits of digital
information obtained by the ADC unit expresses the resolution of the ADC
module.
• The time it takes to convert an analog signal to digital information is called
conversion time. The higher the clock signal frequency to be used for ADC
operation, the faster the conversion process.
Analog Digital Converters
• Most PIC MCUs incorporate analogue inputs that are
internally connected to an ADC that produces a binary
representation of the input voltage. This is generally a 10-bit
conversion,
• which is accurate to 1 part in 1024 (210). This is better than
0.1% at maximum output and precise enough for most
purposes.
• Sometimes, an 8-bit result is sufficient, which gives an
accuracy of 1 part in 256 (0.5%) and is simpler to process.
PIC16F877A Pinout
setup_adc(mode)
• Setting mode
• setup_adc(ADC_OFF);
• setup_adc(ADC_CLOCK_INTERNAL);
• setup_adc(ADC_CLOCK_DIV_2);
• setup_adc(ADC_CLOCK_DIV_8);
• setup_adc(ADC_CLOCK_DIV_32);
setup_adc_ports()
setup_adc_ports(NO_ANALOGS); None
setup_adc_ports(ALL_ANALOG); All analog pins
setup_adc_ports(AN0_AN1_AN2_AN4_VSS_VREF); A0 A1 A2 A5 Vref(+)=A3

setup_adc_ports(AN0_AN1_AN3); A0 A1 A3
setup_adc_ports(AN0_AN1_VSS_VREF); A0 A1 Vref(+)=A3
setup_adc_ports(AN0_AN1_AN4_VREF_VREF); A0 A1 A5 Vref(+)=A3 Vref(-)=A2
setup_adc_ports(AN0_AN1_VREF_VREF); A0 A1 Vref(+)=A3 Vref(-)=A2
setup_adc_ports(AN0); A0
setup_adc_ports(AN0_VREF_VREF); A0 Vref(+)=A3 Vref(-)=A2
ADC Usage
• #define adc = 10
• set_adc_channel(channel)
• unsigned long int value = read_adc();

• Example;
• set_adc_channel(0);
• value = read_adc();
• delay_us(20);
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy