I2C Protocol and RTC Interfacing

Slides:



Advertisements
Similar presentations
I2C bus Inter Integrated Circuits bus by Philips Semiconductors
Advertisements

Lecture 8: Serial Interfaces
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
GURSHARAN SINGH TATLA PIN DIAGRAM OF 8085 GURSHARAN SINGH TATLA
Lecture 27: LM3S9B96 Microcontroller – Inter- Integrated Circuit (I 2 C) Interface.
NS Training Hardware. System Controller Module.
Serial Peripheral Interface Module MTT M SERIAL PERIPHERAL INTERFACE (SPI)
LSU 10/22/2004Serial I/O1 Programming Unit, Lecture 5.
Input/Output mechanisms
System Clocks.
7/23 Inter-chip Serial Communication: SPI and I 2 C Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee.
AT91 Embedded Peripherals
Universal Asynchronous Receiver/Transmitter (UART)
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
I2C Master Core Simulation Environment. I2C Master Core Requirements Coverage (*) Requirement I2C IP RS-906: The I2C IP shall define the period of time,
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
1 Synchronous Serial IO Send a separate clock line with data –SPI (serial peripheral interface) protocol –I 2 C (or I2C) protocol Encode a clock with data.
Features of the new Alibava firmware: 1. Universal for laboratory use (readout of stand-alone detector via USB interface) and for the telescope readout.
Refer to Chapter 15 in the reference book
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
S4525A Peripherals & Enhanced FLASH 1 © 1999 Microchip Technology Incorporated. All Rights Reserved. S4525A Peripherals & Enhanced FLASH 1 Peripherals.
Lecture 4 General-Purpose Input/Output NCHUEE 720A Lab Prof. Jichiang Tsai.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
8255 Programmable Peripheral Interface
The HCS12 SCI Subsystem A HCS12 device may have one or two serial communication interface. These two SCI interfaces are referred to as SCI0 and SCI1. The.
Serial mode of data transfer
I2C Protocol and RTC Interfacing
Serial Communication Buses: I2C and SPI
Tutorial Introduction
Two Wire Interface Another popular serial peripheral interface bus
MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING
Inter-IC Bus (I C) 2.
Chapter 11: Inter-Integrated Circuit (I2C) Interface
RL78 POC and LVD © 2010 Renesas Electronics Corporation. All rights reserved.
Refer to Chapter 10 in the reference book
Introduction to the processor and its pin configuration
CPU Sequencing 6/30/2018.
Programming Microcontroller ADC – Analog Digital Converter
Programmable Interval Timer
SERIAL PORT PROGRAMMING
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Asynchronous Data Transfer Modes.
Two Wire Interface (TWI)
Dr. Michael Nasief Lecture 2
DMA CONTROLLER 8257 Features: It is a 4-channel DMA.
8086/8088 Hardware Specifications
I2C Protocol and RTC Interfacing
I2C PROTOCOL SPECIFICATION
Communication Lines Fundamentals.
Programming Microcontroller
BJ Furman ME 106 Fundamentals of Mechatronics 15NOV2012
EEPROM Comparison – Parallel or Serial
Computer Organization and Design
SPI Protocol and DAC Interfacing
Chapter 7 Features and Interfacing of Programmable Devices for 8085 based systems.
8254 Timer and Counter (8254 IC).
SPI Protocol and DAC Interfacing
Serial Communication Interface: Using 8251
ADC, DAC, and Sensor Interfacing
Jeremy Reed ATMEL AT24C512 2-wire Serial EPROM Jeremy Reed
I2C and RTC Chapter 18 Sepehr Naimi
Programmable Peripheral Interface
Chapter 13 DMA Programming.
82C55 Programmable Peripheral Interface
X1 & X2 These are also called Crystal Input Pins.
Programmable Peripheral Interface
Programmable Data Communication Blocks
I2C Protocol and RTC Interfacing
EUSART Serial Communication.
The Programmable Peripheral Interface (8255A)
Computer Operation 6/22/2019.
Presentation transcript:

I2C Protocol and RTC Interfacing Chapter9 I2C Protocol and RTC Interfacing

I2C Bus Characteristics

I2C Bit Format

START and STOP Conditions

REPEATED START Condition

Byte Format in I2C

Address Byte Format in I2C

Typical Data Transmission

Clock Stretching

Multi-byte Burst Write

Multi-byte Burst Read

I2C Module Base Address for STM32F4xx 0x4000 5400 - 0x4000 57FF I2C2 0x4000 5800 - 0x4000 5BFF I2C3 0x4000 5C00 - 0x4000 5FFF

I2C Master Slave connection

RCC APB1 peripheral clock enable register (RCC_APB1ENR) to enable clock to I2C

Some I2C Registers in STM32F4xx Register Name Register Function Register Address I2C_CR1 Control 1 0x0000 I2C_CR2 Control 2 0x0004 I2C_DR Data 0x0010 I2C_SR1 Status 1 0x0014 I2C_SR2 Status 2 0x0018 I2C_CCR Clock Control 0x001C I2C_TRISE SCL Rising Time 0x0020

I2C_CR1 (Control 1) Register Bit 15 SWRST: Software reset When set, the I2C is under reset state. Before resetting this bit, make sure the I2C lines are released and the bus is free. 0: I2C Peripheral not under reset 1: I2C Peripheral under reset state Bit 10 ACK: Acknowledge enable This bit is set and cleared by software and cleared by hardware when PE=0. 0: No acknowledge returned 1: Acknowledge returned after a byte is received (matched address or data) Bit 9 STOP: Stop generation The bit is set and cleared by software, cleared by hardware when a Stop condition is detected, set by hardware when a timeout error is detected. In Master Mode: 0: No Stop generation. 1: Stop generation after the current byte transfer or after the current Start condition is sent. In Slave mode: 1: Release the SCL and SDA lines after the current byte transfer. Bit 8 START: Start generation This bit is set and cleared by software and cleared by hardware when start is sent or PE=0. 0: No Start generation 1: Repeated start generation 1: Start generation when the bus is free Bit 0 PE: Peripheral enable 0: Peripheral disable 1: Peripheral enable

I2C_CR2 (Control 2) Register Bits 5:0 FREQ[5:0]: Peripheral clock frequency The FREQ bits must be configured with the APB clock frequency value (I2C peripheral connected to APB). The FREQ field is used by the peripheral to generate data setup and hold times compliant with the I2C specifications. The minimum allowed frequency is 2 MHz, the maximum frequency is limited by the maximum APB frequency (42 MHz) and cannot exceed 50 MHz (peripheral intrinsic maximum limit). 0b000000: Not allowed 0b000001: Not allowed 0b000010: 2 MHz ... 0b110010: 50 MHz Higher than 0b101010: Not allowed

I2C Clock Control register (I2C_CCR) Bit 15 F/S: I2C master mode selection 0: Sm mode I2C 1: Fm mode I2C Bit 14 DUTY: Fm mode duty cycle 0: Fm mode tlow/thigh = 2 1: Fm mode tlow/thigh = 16/9 (see CCR) Bits 13:12 Reserved, must be kept at reset value Bits 11:0 CCR[11:0]: Clock control register in Fm/Sm mode (Master mode) Controls the SCL clock in master mode. Sm mode or SMBus: Thigh = CCR * TPCLK1 Tlow = CCR * TPCLK1

I2C Frequency Selection in I2C_CR2 Register FREQ[5:0] in binary Allowed Freq 000000 Not allowed 000001 000010 2 MHz (minimum acceptable for Standard mode) 000011 3 MHz 000100 4 MHz (minimum acceptable for Fast mode) 000101 5 MHz 000110 6 MHz 000111 7 MHz 001000 8 MHz ...   … 010000 16 MHz 110010 50 MHz Higher than 0b100100: Not allowed

I2C TRISE register (I2C_TRISE) Bits 15:6 Reserved, must be kept at reset value Bits 5:0 TRISE[5:0]: Maximum rise time in Fm/Sm mode (Master mode) These bits should provide the maximum duration of the SCL feedback loop in master mode. The purpose is to keep a stable SCL frequency whatever the SCL rising edge duration. These bits must be programmed with the maximum SCL rise time given in the I2C bus specification, incremented by 1.

I2C_DR (Data Register) for Transmit/Receive Buffer Register Bits 7:0 DR[7:0] 8-bit data register Byte received or to be transmitted to the bus. – Transmitter mode: Byte transmission starts automatically when a byte is written in the DR register. A continuous transmit stream can be maintained if the next data to be transmitted is put in DR once the transmission is started (TxE=1) – Receiver mode: Received byte is copied into DR (RxNE=1). A continuous transmit Stream can be maintained if DR is read before the next data byte is received (RxNE=1).

I2C Status Register 1 (I2C_SR1)

I2C Status Register 1(I2C_SR1) Bit Description Bits Field Description 7 TxE Data register empty (transmitter) This is set when the transmit data register is empty and a byte of data can be written into the data register 0: Data register not empty 1: Data register empty 6 RxNE Data register not empty (receiver) This is set when a byte is received in receive mode 0: Data register empty 1: Data register not empty 2 BTF Byte transfer finished In transmit mode, it is set when all the data are transmitted. The program should wait until this bit is set before issuing a stop condition. In receive mode, it is set when a byte of data is received. The program should wait until this bit is set before reading from the data register. 0: data byte transfer not done 1: data byte transfer succeeded

I2C pins in STM32F4xx (See Appendix B full listing) Function PB6 I2C1_SCL PB7 I2C1_SDA PB8 PB9 PB10 I2C2_SCL PB11 I2C2_SDA PA8 I2C3_SCL PC9 I2C3_SDA

Alternative pin function multiplexing (See Appendix B for full List)

GPIOx_MODER Register Options Bits 2y:2y+1 MODERy[1:0]: Port x configuration bits (y = 0..15) These bits are written by software to configure the I/O direction mode. 00: Input (reset state) 01: General purpose output mode 10: Alternate function mode 11: Analog mode

AFRL Register

DS1337 Pins

STM32F4xx Connections to RTC

DS1337 Address Map

Simplified Structure of SQW/INTB Pin

RS bits RS2 RS1 Output Frequency 1 Hz 1 4.096 kHz 8.192 kHz 32.768 kHz

Alarm 2 Register Mask Bits DY/DT A2M4 A2M3 A2M2 Alarm Rate X 1 Alarm once per minute Alarm when minutes match Alarm when hours and minutes match Alarm when date, hours, and minutes match Alarm when day, hours, and minutes match