pic_13

35
PIC Peripheral Interface Controllers SPI protocol and RTC DS1306 interface Amit Kulkarni

Upload: amitk25

Post on 08-Feb-2016

28 views

Category:

Documents


0 download

DESCRIPTION

microcontroller

TRANSCRIPT

Page 1: PIC_13

PIC Peripheral Interface Controllers

SPI protocol and RTC

DS1306 interface

Amit Kulkarni

Page 2: PIC_13

Objectives

Page 3: PIC_13

MSSP module

� Master synchronous module is a serial

interface.

Useful for communicating with other� Useful for communicating with other

peripheral or microcontroller devices.

� These peripheral devices may be serial

EEPROMs, shift registers, display drivers,

A/D converters, etc.

Page 4: PIC_13

MSSP module

� The MSSP module can operate in one of two modes:

– Serial Peripheral Interface (SPI)

– Inter-Integrated Circuit (I2C)– Inter-Integrated Circuit (I2C)

� Full Master mode

� Slave mode (with general address call)

� The I2C interface supports the following modes in

hardware:

– Master mode

– Multi-Master mode

– Slave mode

Page 5: PIC_13

Control registers

� The MSSP module has three associated

registers.

These include a status register (SSPSTAT)� These include a status register (SSPSTAT)

and two control registers (SSPCON1 and

SSPCON2).

� The use of these registers and their

individual configuration bits differ significantly

depending on whether the MSSP module is

operated in SPI or I2C mode.

Page 6: PIC_13

SPI mode

� Originally started by Motorola Corp.

� Used in many devices such as ADC,DAC, EEPROM etc.

� The SPI mode allows 8 bits of data to be synchronouslyThe SPI mode allows 8 bits of data to be synchronouslytransmitted and received simultaneously.

� To accomplish communication, typically three pins are used:

• Serial Data Out (SDO) – RC5/SDO

• Serial Data In (SDI) – RC4/SDI/SDA

• Serial Clock (SCK) – RC3/SCK/SCL

Page 7: PIC_13

SPI read write

� uC is used as master and SPI device is used

as slave.

uC generates the SCLK which is fed to the� uC generates the SCLK which is fed to the

SCLK pin of SPI device.

� This synchronizes the transfer operation one

bit at time.

� MSB goes first, CE remains HIGH.

Page 8: PIC_13

SPI read write

� Information is transferred in groups of 8-bits.

� Address is immediately followed by the data.

� To distinguish between the read and write

operations:

– D7 bit of address byte is always HIGH (1) for write

– D7 bit of address byte is always LOW (0) for read

Page 9: PIC_13

Steps for writing

Page 10: PIC_13

Timing

Page 11: PIC_13

Multi-byte burst write

Page 12: PIC_13

Steps for reading data from SPI

Page 13: PIC_13

Steps for reading data from SPI

Page 14: PIC_13

DS1306 RTC interfacing

� Pin description

Page 15: PIC_13

DS1306 Pin description

Page 16: PIC_13

DS1306 Pin description

Page 17: PIC_13

DS1306 Pin description

Page 18: PIC_13

DS1306 Pin description

Page 19: PIC_13

Control registers

Page 20: PIC_13

Status register

Page 21: PIC_13

RTC registers and address map

� It has total 128 bytes of RAM space.

Page 22: PIC_13

RTC registers and address map

Page 23: PIC_13

RTC registers and address map

Page 24: PIC_13

Address locations for time and date

Page 25: PIC_13

Power supply configurations

Page 26: PIC_13

Power supply configurations

Page 27: PIC_13

Power supply configurations

Page 28: PIC_13

Interfacing using MSSP module

� The associated registers are

– SSPBUF: holds the byte to be transmitted or

received.received.

– SSP1CON: SPI mode selection of PIC18

– SSPSTAT: Status flags.

All are 8-bits wide.

Page 29: PIC_13

SSPSTAT: MSSP STATUS REGISTER (SPI MODE)

Page 30: PIC_13

SSPSTAT: MSSP STATUS REGISTER (SPI MODE)

Page 31: PIC_13

SSPCON1: MSSP CONTROL REGISTER 1 (SPI MODE)

Page 32: PIC_13

SSPCON1: MSSP CONTROL REGISTER 1 (SPI MODE)

Page 33: PIC_13

Connections

Page 34: PIC_13

Assignments: PIC18F4520

1. Develop the C program for interfacing

DS1306 RTC interfacing, and simulate

results on proteus.results on proteus.

2. Simulate the capture mode programming.

3. Simulate the compare mode programming.

4. Interface DC motor using PWM , for

different duty cycles.

5. Use the above code to implement a water

fountain.

Page 35: PIC_13

Assignments: PIC18F4520

6. Implement up-down counter using RTC

DS1306 and LCD 16x2.

7. Implement stop-watch using RTC, LCD and 7. Implement stop-watch using RTC, LCD and

keys.

8. Study and implement ALARM features of

DS1306 in assembly and C.