Top Banner
4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria [email protected] BEH30802 :: REAL-TIME EMBEDDED SYSTEM
20

4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria [email protected] BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

Dec 26, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

4.0 RTOS IMPLEMENTATIONPART II

Mohamad Fauzi bin [email protected]

BEH30802 :: REAL-TIME EMBEDDED SYSTEM

Page 2: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

ChibiOS/RT – Part II

4.5. Introduction to Serial Communication Protocol

4.6. Universal Asynchronous Receiver Transmitter (UART)

4.7. Inter-integrated Communication (I2C)

4.8. Serial Peripheral Interface (SPI)

Page 3: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

OVERVIEW

Serial

Receiver

Transmitter Parallel

Receiver

Transmitter

1 bit

1 word

Page 4: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SERIAL VS PARALLELSERIAL PARALLEL

COST Cheap Expensive

SPEED Slow Fast

TRANSMISSION AMOUNT

Single bit8 bits (8 data lines) Transmitter &

Receiver

TRANSMISSION LINES

One line to transmit one to receive

8 lines for simultaneous transmission

TRANSMISSION DISTANCE

LongShort distance

(synchronization)

Page 5: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

DATA TRANSMISSION

Page 6: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SERIAL COMMUNICATION METHOD

Page 7: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.
Page 8: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

IN-VEHICLE NETWORK

Page 9: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

RS232 - UART

Signal level: TTL (direct) or RS232(needs line driver)

Was set by the Electronics Industries Association (EIA) in 1960, before the advent of TTL logic family.

Therefore, logic 1 is represented by “-3 to -25V”, and logic 0 is “+3 to +25V”. Two types of RS232 pins: DB-25 and DB-9. Most important pins are Tx, Rx, and

ground. To interface with microcontroller, we need line driver such as MAX232 (need

capacitors) or MAX233 (no capacitors).

Common baud rate: 9600 or11.2k bps

Page 10: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

RS232 VS TTL

RS232

TTL

Page 11: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

EXAMPLE OF TTL UART

Page 12: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

INTER-INTEGRATED CIRCUIT (I2C)

Developed by Philips Semiconductor for TV sets in the 1980’s

I2C devices include EEPROMs, thermal sensors, and real-time clocks

Used as a control interface to signal processing devices that have separate data interfaces, e.g. RF tuners, video decoders and encoders, and audio processors.

Limited to about 10 feet for moderate speeds

Page 13: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

I2C BUS CONFIGURATION

2-wire serial bus – Serial data (SDA) and Serial clock (SCL)

Half-duplex, synchronous, multi-master bus

No chip select or arbitration logic required

Lines pulled high via resistor

Page 14: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

I2C PROTOCOLCommunication Speed (Data rate)1. Normal mode: 100 kHz2. Fast mode: 400 kHz3. Fast mode plus: 1MHz4. High-speed mode: 3.4MHz5. Ultra-fast mode: 5MHz

Page 15: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

I2C TRADEOFFS

• Good for communication with on-board devices that are accessed occasionally.

• Easy to link multiple devices because of addressing scheme

• Cost and complexity do not scale up with the number of devices

Advantages

• The complexity of supporting software components can be higher than that of competing schemes (for example, SPI ).

Disadvantages

Page 16: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SERIAL PERIPHERAL INTERFACE (SPI)

Defined by Motorola on the MC68HCxx line of microcontrollers

Generally faster than I2C, capable of several Mbps

Applications:• Like I2C, used in EEPROM, Flash, and real time clocks• Better suited for “data streams”, i.e. ADC converters• Full duplex capability, i.e. communication between a codec

and digital signal processor

Page 17: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SPI BUS CONFIGURATION

Synchronous serial data link operating at full duplex

Master/slave relationship• MOSI – master data output, slave data input• MISO – master data input, slave data output2 data signals:• SCLK – clock• /SS – slave select (no addressing)2 control signals:

Page 18: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SPI VS. I2C• Less overhead

than I2C due to lack of addressing, plus SPI is full duplex.

For point-to-point, SPI is simple

and efficient

• More effort and more hardware than I2C

For multiple slaves, each slave needs

separate slave select signal

Page 19: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SPI PROTOCOL

Master and slave must agree on parameter pair

values in order to communicate

2 Parameters, Clock Polarity (CPOL) and Clock Phase (CPHA), determine

the active edge of the clock

CPOL CPHA Active edge

0 0 Rising

0 1 Falling

1 0 Falling

1 1 Rising

Page 20: 4.0 RTOS IMPLEMENTATION PART II Mohamad Fauzi bin Zakaria mfauzi@uthm.edu.my BEH30802 :: REAL-TIME EMBEDDED SYSTEM.

SPI PROTOCOL (CONT.)