An Overview Of DS3232
DS3232 is an I2C protocol based RTC (real time clock) with a digital temperature inside. Its RAM store date/time, temperature and also a general purpose SRAM space.
A sample of program simulation |
The device works at +3.3 V designed to fit any portable low power electronic applications. It's a 20-pin SMD device, requiring only a few external components. A very precise 32.768 kHz internal oscillator creates a timing for the device date/time. To keep the time working whenever it's power off, an external coin battery needed to connect to the Vbat pin of the IC.
DS3232 IC And Pins Diagram |
Each pin has its function as lists below.
Pins description of DS3232 from device's datasheet |
The I2C Interface
For DS3232 this communication protocol could clocks up to 400 kHz from the master device. The device writing address is the same to DS1307. The writing address for this device is 0xD0 while the reading address is 0xD1.
Master MCU writes to DS3232 |
Master MCU reads from DS3232 |
Address Map
Just like DS1307 the starting address of 0x00 is the second register.
Control Register
Control Register |
- BIT 7 - Enable Oscillator: When device is powered on it's set to '0' to enable the oscillator. Setting this bit to '1', the device switch off from the oscillator.
- BIT 6 - Battery-backed Square-wave Enable: If not necessary do not access to this bit.
- BIT 5 - Convert Temperature: Setting this bit to '1' to enable temperature conversion. The temperature is 10-bit wide, and will be list next. The conversion takes at least 2 mS.
- BIT 4:3 - Rate Select (RS2:1): They set the output frequency from INT/SQW pin.
Square-wave output frequency |
- BIT 2 - Interrupt Control: Setting this bit to 0 to enable the square wave output from INT/SQW pin.
- BIT 1 - Alarm 2 Interrupt Enable: I don't use it here, please see the device's datasheet.
- BIT 0 - Alarm 1 Interrupt Enable: I don't use it here, please see the device's datasheet.
Control/Status Register
- BIT 7 - Oscillator Stop Flag: If it's '1' indicates that the oscillator is stop working.
- BIT 6 - Battery-backed 32 kHz Output: If it's set to '1', it enable the 32 kHz output from the 32kHz pin when powered from the back up battery.
- BIT 5:4 - Conversion Rate: These two bits determine the rate of temperature conversion (TCXO).
Conversion rate |
- BIT 3 - Enable 32 kHz Output: When this bit is set to '1' it enable the 32 kHz square wave output from the 32 kHz pin.
- BIT 2 - BUSY: When this bit is read '1' indicates that the temperature conversion (TCXO) is not completed.
- BIT 1 - Alarm 2 Flag: When it's set to '1' it indicates the time is matched in the alarm 2 register.
- BIT 0 - Alarm 1 Flag: When it's set to '1' it indicates the time is matched in the alarm 1 register.
Temperature Registers
A digital thermometer is integrated inside the chip. Temperature data made of two bytes - the upper byte (0x11) and the lower byte(0x12).
At the upper byte the MSB bit 7 indicate the sign of temperature. When bit 7 is set to '1' it's at negative temperature environment. Then the upper temperature data must converter to 2'complement.
SRAM
Interfacing And Programming.
With a software I2C library in CCS PICC, communicating with this device is pretty easy. Two SDA and SCL pins could be any pins within the I/O pin of the master MCU.
Schematic Diagram |
No comments:
Post a Comment