Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with RTC Chip DS1307 with PIC18F452 using Hi-Tech C

Status
Not open for further replies.

saeed_pk

Full Member level 4
Joined
May 20, 2006
Messages
237
Helped
35
Reputation
68
Reaction score
28
Trophy points
1,308
Location
Islamabad, Pakistan
Activity points
2,655
ds1307 pic18f4550

Hi all,
I am trying to use RTC Chip DS1307 with PIC18F452 to make a Clock this clock is to be updated by GPS Receiver. I am usinf PICC18 by HTSOFT,
please tell whether this RTC used SPI or I²C and if any one had done this with HTSOFT and PIC please tell me if you can upload code please do so.
I need to do it on Hardware MSSP module so please help me!
 

ds1307 con pic18f452

please tell whether this RTC used SPI or I²C
Did you lost the datasheet? I2C is written on the title page. You should try to locate it, cause it has other valuable information for your project, too.

DS1307 can obviously be accessed through MSSP, but unfortunatley I can't help with HI-TECH related code. I prefer the possibly less professional (can be understood and succesfully operated by occasional programmers more easily) CCS compiler.
 

ds1307 y pic18f

There is a driver of 1302 in CCS does it make a software I2C or utilizes MSSP
thanks
 

hi-tech ds1307

DS1302 in contrast to DS1307 isn't I2C, it's µwire-like synchronous serial. It uses a software driver, I think. But with CCS, you can service I2C with built-in functions, e. g.:

Code:
#define RTC_READ     0xD1
#define RTC_WRITE    0xD0
#define TIME_ADR     0x00
#define DATE_ADR     0x04
#define ALRM1_ADR    0x07
#define ALRM2_ADR    0x0B
#define CONF_ADR     0x0E
#define Stat_ADR     0x0F
#define MASK_HOUR    0x3F
#define MASK_MONTH   0x1F

void GetTime ( BYTE *bHours, BYTE *bMinutes, BYTE *bSeconds )
{
   i2c_start();
   i2c_write( RTC_WRITE );    // Set RTC in Write Mode
   i2c_write( TIME_ADR );     // Set the Adress to read
   i2c_stop();

   i2c_start();
   i2c_write( RTC_READ );   // Set RTC in Read Mode
   *bSeconds = i2c_read();  // Read Second from RTC
   *bMinutes = i2c_read();  // Read :      from RTC
   *bHours   = i2c_read(0); // Read :      from RTC
   *bHours  &= MASK_HOUR;   // Mask the Hours
   i2c_stop();
}
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top