As a part of ALA in the subject of MCI (2151001) subject faculty:Hiren Patel Sir Presentation on rtc interfacing with atmega32 using ds1307 By:selva kumar.r.

Slides:



Advertisements
Similar presentations
Review: Interrupts & Timers
Advertisements

EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
Serial Interfaces, Part Deux -I 2 C and SPI December 4, 2002 Presented by Eugene Ho.
Lecture 8: Serial Interfaces
SPI on the ATmega SS’ line only used in Slave mode SPDR
USART and Asynchrono us Communica tion The USART is used for synchronous and asynchronous serial communication. USART = Universal Synchronous/Asynchronous.
Electronic Guidance Device(EGD) Group Members Stephen Harris Abdul-Karim Al-Shanfari Bradley Smethie Robert Bornhijm.
Two Wire Interface Another popular serial peripheral interface bus -More flexible than SPI -Master and slave modes supported -7-bit slave address -400khz.
The Headphones1 Trainer Training The Headphones. 2 There are three sets of headphones There are three transmitters Transmitters also act as battery chargers.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
Renesas Electronics Europe GmbH A © 2010 Renesas Electronics Corporation. All rights reserved. RL78 Clock Generator.
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Microprocessor based Design for Biomedical Applications MBE 3 – MDBA III : The ATmega8 Basic Features (2)
Industrial Reference Design Platform RS-232 Interface Developed by the TSC Americas Release 1.0.
Held AT EDA AND EMBEDDED SYSTEM
ELE22MIC Lecture 18 The AVR Sleep Modes The ATMEGA128’s Timer System
CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming.
Senior Design Dec06-04 Diana Calhoun (Communication Coordinator) Matt Koch (Group Leader) Kelly Melohn (Communication Aide) Yesuratnam Thommandru (Group.
Presented by: © 2015 Jacob Beningo All Rights Reserved Writing Portable and Robust Firmware in C September 2, 2015 Jacob Beningo, CSDP Class 3: Uart Driver.
WCL 조윤정 Arduino Bootloader 코드 분석. BAUD_RATE 설정 /* set the UART baud rate defaults */ #ifndef BAUD_RATE #if F_CPU >= L #define BAUD_RATE.
Communicating. The ATmega16 communicates through one of the following ways: Serial Peripheral Interface (SPI) Universal Synchronous and Asynchronous serial.
Chap.6.3 UART.
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
A.D.Patel institute of technology Sub : LCD and Keyboard interfacing with AVR. prepared by, chokshi abhi p ( ) Guided by, Prof. Asif Thakor.
Module 8 Tutorial  An 8086 system is used for controlling the speed of a motor. The motor can operate at 5 different speeds (1- 5).  The speed.
Sitarambhai Naranjibhai Patel Institute of Technology and Research Centre, Umrakh, Bardoli. A Presentation On “ 16x2 LCD Interfacing with AVR atmega32.
MICROCONTROLLER AND INTERFACING Presented by: Shefali Jethva ( ) Shivali Panchal ( ) Komal Soni ( ) Roll no. :- 14EC308.
INTERFACING KEYBOARD WITH ATMEGA32 ELECTRONICS & COMMUNICATION TITLE.
Revision questions CENG2400 v.14b 1 CENG2400 Revision, Question 1 A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module.
 The LPC2xxx devices currently have two on- chip UARTS.  Except UART1 has additional modem support.
Ultra Trace Cargo Monitoring Kevin Kurtz - ECE Jacob Klapheke - ECE Nick Searcy - ECE Nick Wood - ME Jason Guelda - ME.
SUBMITTED BY EDGEFX TEAM
NFC Sensor System ECE Winter 2015
CC2430 module Jinho Son Real-Time System Lab.
LCD Interfacing using Atmega 32
I2C Protocol and RTC Interfacing
Embedded Systems Programming Examples and Comparison
Two Wire Interface Another popular serial peripheral interface bus
Figure SPI Single-Byte Write Timing (Notice A7 = 1)
MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING
ECE 353 Introduction to Microprocessor Systems
UNIVERSAL COLLEGE OF ENGINEERING & TECHNOLOGY
COMP2121: Microprocessors and Interfacing
ATMEGA 32 CONNECTIONS TO RS232; UDR AND UCSR REGISTERS
I2C Synchronous Serial Two wire communications (plus ground)
Atmega32 Serial Programming Basics
I2C Protocol and RTC Interfacing
I2C PROTOCOL SPECIFICATION
The Arduino Microcontroller: Atmel AVR Atmega 328
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Future Designs, Inc. Your Development Partner
UART Protocol Chapter 11 Sepehr Naimi
I2C and RTC Chapter 18 Sepehr Naimi
I2C Protocol and RTC Interfacing
Lecturer: Reza Arjmandi Autumn 2015
Преглед Начин функционисања Имплементације
8085 Microprocessor Architecture
Configuration and Programming
I2C transmittion specificataion
ADC and DAC Programming in AVR
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Important 8051 Features On chip oscillator 4K bytes ROM 128 bytes RAM
I2C Protocol and RTC Interfacing
Paul MacDougal Triembed.org Dec 11, 2017
Introduction To Computing BBA & MBA
Lecture 17.
Serial Communication 19th Han Seung Uk.
Using FPro SoC with customized hardware cores
Presentation transcript:

As a part of ALA in the subject of MCI ( ) subject faculty:Hiren Patel Sir Presentation on rtc interfacing with atmega32 using ds1307 By:selva kumar.r ec dept sem 5: enroll no:

Contents inside:-  Introduction  Internal registers  Simple RTC module  Reading internal register in RTC using codes  DS 1307 with Atmega32  Schematic diagram of the interfacing

Introduction  Real Time Clocks, as the name suggests are clock modules. They are available as integrated circuits (ICs) and manages timing like a clock. Some RTC ICs also manages date like a calendar. The main advantage is that they have a system of battery backup which keeps the clock/ca lender running even in case of power failure. A very small current is required for keeping the RTC alive. This in most case is provided by a miniature 3v lithium coin cell. So even if the embedded system with RTC is powered off the RTC module is up and running by the backup cell. his same technique is used in PC timing also. If you have opened your computer case you will notice a small coin cell in the mother board.

 The DS1307 is a low-power clock/calendar with 56 bytes of battery-backed SRAM. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The DS1307 operates as a slave device on the I2C bus.

Internal Registers ADDRESSBIT7BIT6BIT5BIT4BIT3BIT2BIT1BIT0FUNCTIONRANGE 00H CH10 SECONDSSECOND H 010 MINUTESMINUTES H HR HOUR 1-12+AM/PM OR am/pm 03H 00000DAY H 0010 DATEDATE H 00010MONTHMONTH H 10 YEARYEAR H TO KEEP THINGS SIMPLE I HAVE SKIPPED THE CONTROL REGISTER THIS IS USED FOR SQUARE WAVE GENERATION ON PIN7 08-3FH 56 BYTE RAM00h-FFh

Simple RTC module  The DS1307 require an KHz crystal, a 3v lithium battery and 2 pull up registers to function. So I will make a small PCB that will hold all these. The image of module is shown below. The module can be connected to development boards using female-female burg wires.DS KHz crystaldevelopment boardsfemale-female burg wires

Code to read internal register in RTC address : Address of the register data: value of register is copied to this. Returns: 0= Failure 1= Success ***************************************************/ uint8_t DS1307Read(uint8_t address,uint8_t *data) /*************************************************** Function To Write Internal Registers of DS address : Address of the register data: value to write. Returns: 0= Failure 1= Success ***************************************************/ uint8_t DS1307Write(uint8_t address,uint8_t data)

RTC DS(1307) interfacing with Atmega 32  # include  void init_i2c()  {  TWSR = 0X00;  TWBR = 0X47;  TWCR = (1<<TWEN);  }

 unsigned char read_i2c()  {  TWCR = (1<<TWINT)|(1<<TWEN);  while(!(TWCR & (1<<TWINT)));  return TWDR;  }  void write_i2c(unsigned char ch)  {  TWDR = ch;  TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA);  while(!(TWCR&(1<<TWINT)));  }

 void start()  {  TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN);  while((TWCR &(1<<TWINT))==0);  }  void stop()  {  TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWSTO);  _delay_ms(1);  }

 void rtc_write(char dev_addr,char dev_loc,char dev_data)  {  start();  write_i2c(dev_addr);  write_i2c(dev_loc);  write_i2c(dev_data);  stop();  _delay_ms(10);  }

 unsigned char rtc_read(char dev_addr,char dev_loc)  {  char ch;  start();  write_i2c(dev_addr);  write_i2c(dev_loc);  start();  write_i2c(dev_addr|0x01);  ch = read_i2c();  stop();  return ch;  }

 void tx( unsigned char data )  {  while ( !(UCSRA & (1<<UDRE)) ); // wait until UDR is empty  UDR = data;  }  char rx()  {  while ( !(UCSRA & (1<<RXC)) ); // wait until UDR is empty  return UDR;  }

 void init_serial()  {  UCSRB = (1<<RXEN)|(1<<TXEN);  UCSRC = (1<<UCSZ1)|(1<<UCSZ0);  UBRRL = 51;  }  void str_serial(char *str)  {  while(*str)  {  tx(*str++);  _delay_ms(1);  }

 void disp_time_date()  {  char ch;  tx(254);  tx(128);  str_serial("Time: ");  ch = rtc_read(0xd0, 0x02);  tx(ch/16+48);  tx(ch%16+48);  tx('-');

 ch = rtc_read(0xd0, 0x01);  tx(ch/16+48);  tx(ch%16+48);  tx('-');  ch = rtc_read(0xd0, 0x00);  tx(ch/16+48);  tx(ch%16+48);  tx(254);  tx(192);

 str_serial("Date: ");  ch = rtc_read(0xd0, 0x04);  tx(ch/16+48);  tx(ch%16+48);  tx('-');  ch = rtc_read(0xd0, 0x05);  tx(ch/16+48);  tx(ch%16+48);  tx('-');

 ch = rtc_read(0xd0, 0x06);  tx(ch/16+48);  tx(ch%16+48);  }

 int main()  {  DDRC =0XFF; DDRD =0XFF;  init_i2c();  init_serial();  rtc_write(0xd0,0x00,0x00);  rtc_write(0xd0,0x01,0x27);  rtc_write(0xd0,0x02,0x08);  rtc_write(0xd0,0x04,0x08);  rtc_write(0xd0,0x05,0x09);  rtc_write(0xd0,0x06,0x13);  _delay_ms(10000);

 while(1)  {  disp_time_date();  }

Schematic of the interfacing T h e E n d...