Presentation is loading. Please wait.

Presentation is loading. Please wait.

MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING

Similar presentations


Presentation on theme: "MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING"— Presentation transcript:

1 MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING
RTC INTERFACING Prepared by, Guided by, Group 05,EC(SEM-05) Prof. Hitesh Patel Ajmal Mulla Bharat Jangid Mazdad Anklesaria Neelamber Beshra

2 Table of contents Sr. No. Topic 01 RTC interfacing 02 DS1307 pin out
03 Address map of DS1307 04 DS1307 control register 05 Register Pointer 06 Writing to DS1307 07 Reading From DS1307

3 RTC INTERFACING The (RTC) Real Time clock is a widely used device that provides accurate time and data information for many applications. Many applications such as x86 PC comes with such a chip on board. The RTC chip on x86 PC provides the time components of hour, minute and second in addition to date/calendar components of year, month and day.

4 According to DS1307 data sheet from Maxim, clock calendar provides seconds, minutes, hours, day, date, month and year information. The clock operates in either 24 or 12 hour format with AM/PM indicator. The DS1307 has an inbuilt power sense circuit that detects power failures and automatically switches to the battery supply.

5 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.

6 DS1307 PINOUT

7 -X1 and X2: These are the input pins that allows DS1307 connection to an external clock crystal oscillator to provide clock source to the chip. Standard KHz quartz crystal must be used. Accuracy of clock depends on quality of crystal oscillator.

8 Vbat: Pin 3 can be connected to an external +3V lithium battery, thereby providing power source to chip when external supply voltage is not available. We must connect this pin to ground if it is not used. A 48mAhr lithium battery can provide the power needed for more than 10 years to back up the chip.

9 -GND: Pin 04 is the Ground. -SDA(Serial Data): Pin 05 is the SDA pin and must be connected to SDA line of 12C bus. -SCL(Serial Clock):Pin 06 is the scl pin and must be connected to scl line of 12C bus. -SWQ/OUT : Pin 07 is an output pin providing 1,4,8, or 32KHz frequency if enabled. It needs an ext. pull up resistor to generate the frequency as it open drain.

10 -Vcc: Pin 08 is used as primary voltage supply to the chip which is generally set to +5V. When Vcc falls below Vbat level,DS1307 switches to Vbat and external Lithium battery provides power to the RTC. According to DS1307 datasheet, upon power up, the device switches from Vbat to Vcc1 when Vcc1 is greater than Vbat+0.2 volts. Vcc voltage level must remain above 3.2V In order for the Vcc to remain as primary voltage source to the chip, and it must be more than 3.75V if we want to access the chip.

11 Address map of the DS1307 From software point of view the DS1307 is just a collection of some 8 bit registers. You can read these register to obtain the current time and date. We can also modify them to hold the correct time. After that the DS1307 keeps then updated with current date and time.

12 DS1307 Internal Registers ADDRESS Bit7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1
FUNCTION RANGE 00H CH 10 seconds seconds Seconds 00-59 01H 10 minutes minutes 02H 12 10 hr 10 hour Hours hours 1-12 AM/PM 00-23 24 PM/AM 03H day 01-07 04H 10 date date 01-31

13 05H 10 month Month month 01-12 06H 10 year year 00-99 07H out SQWE RS1 RS0 Control - 08H-3FH RAM56x8 00H-FFH

14 DS1307 Control register OUT SQWE RS1 RS0

15 -OUT:(OUTPUT CONTROL) If square wave output is disabled, setting OUT bit to 1 will make SQW/OUT pin low, and clearing OUT bit to 0 will make this bit high. -SQWE:(Square Wave Enable) If this bit is set, oscillator output is enabled else it is disabled.

16 -RS1-RS0(rate select): This bits selects the output frequency of oscillator output according to following table: RS1 RS0 o/p frequency 1Hz 1 4.096KHz 8.192KHz 32.768KHz

17 Time and data address locations and modes
The byte addresses 06 are set aside for time and date. The DS1307 provides data in BCD form only. Notice the data range for hour mode. We can select 12/24 hour mode with bit06 of hour location 02. When D6=1,12 hour mode is selected and vice-versa. In 12hour mode we decide AM and PM with bit05.If D5=0, AM is selected and vice-versa.

18 Register Pointer In DS1307 there is a register pointer that specifies the byte that will be accessed in next write or read command. After each read or write operation, content of register pointer is automatically incremented. It is useful in multi-byte read or write.

19 Writing to DS1307 To set value of register pointer(R.P.) and write one or more bytes of data we can use following steps: (i)To access Ds1307 for a write operation, after sending a start condition we should transmit the address of DS1307( ) followed by 0 to indicate a write operation. (ii)The 1st byte of data in write operation will set RP. Example: if we want to access control register we should send 0x07.

20 If we only want to set RP then we should skip this step
If we only want to set RP then we should skip this step. If we want to write 1 or more bytes of data we should transmit them 1 byte at a time. Transmit a Stop bit condition.

21 Reading From DS1307 To read 1 or more bytes of data from DS1307 we must take following steps: (i)To access DS1307 for a read operation, after sending a start condition, we should transmit the address of DS1307( ) followed by 1 to indicate a write operation. (ii)Now we can read 1 or more bytes of data. Notice that RP indicates which register is to be read.

22 (iii)Also notice that RP is automatically incremented and we can simply receive consecutive bytes of data in a multi-byte burst read. (iv)Transmit a stop bit condition.

23 Conclusion From this Active Learning Assignment, we can study about RTC interfacing and its working.

24 Reference The AVR Microcontroller and Embedded Systems using Assembly and C. Muhammad Ali Mazidi Sarmad Naimi Sepehr Naimi

25 THANKYOU


Download ppt "MGITER,NAVSARI. AVR MICROCONTROLLER AND INTERFACING"

Similar presentations


Ads by Google