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.

need help with program to interface DS1307 with 16F877

Status
Not open for further replies.

elizabeth ann

Junior Member level 2
Joined
Feb 16, 2008
Messages
21
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,468
ds1307 ccs

hello everyone.

i'm new here, i would like to ask for some assistance regarding my project, which on interfacing DS1307 with 16F877. basically i will be using this on my programmable medicine dispenser, and i need DS1307 as my clock source and synchronization so that the medications will always be on time. how do i call the DS1307 so that if a preset time is reached (input through keypad), the microcontroller will signal an alarm and a blinking LED indicator?
by the way, i'm using C language and CCS C Compiler.

Thank you very much.

Elizabeth Ann
 

ds1307+ccs

elizabeth ann said:
hello everyone.

i'm new here, i would like to ask for some assistance regarding my project, which on interfacing DS1307 with 16F877. basically i will be using this on my programmable medicine dispenser, and i need DS1307 as my clock source and synchronization so that the medications will always be on time. how do i call the DS1307 so that if a preset time is reached (input through keypad), the microcontroller will signal an alarm and a blinking LED indicator?
by the way, i'm using C language and CCS C Compiler.

Thank you very much.

Elizabeth Ann

hello i have not much command on C.

but i can say that you have to use I2C commuincation of DS1307 with you PIC MCU.

and for that first I2C funda must be cleared.
so your work will be easy.

for storing time there are two ways ::
1) you can do it mannually using keypad or
2) take system time as reference from your PC.
 

ds1307 interfacing with 16f877

hello H_D_R...

that's correct, i am using PIC 16F877a as my microcontroller.

how do i store time manually using keypad and how can i check if my preset time is reached?

thanks a lot.

elizabeth ann
 

16f877 ds1307

elizabeth ann said:
hello H_D_R...

that's correct, i am using PIC 16F877a as my microcontroller.

how do i store time manually using keypad and how can i check if my preset time is reached?

thanks a lot.

elizabeth ann

r u storing just clock or alarm too...??
 

ds1307 16f877

wow, very fast reply, thank you.

yes i am storing both the alarm and the clock.

i am using DS1307 with 16F877a, and i am constructing the program in CCS C.

any suggestions? thank you again.
 

ccs ds1307

elizabeth ann said:
wow, very fast reply, thank you.

yes i am storing both the alarm and the clock.

i am using DS1307 with 16F877a, and i am constructing the program in CCS C.

any suggestions? thank you again.

sorry to say but i dont have any experience of 16F877a not even CCS C too.

i am using 89S52 with DS1307 in ASM language.
so i can help you only DS1307 side part. but if you can understand flow then you can implement in your CCS C.
please let me know have u read datasheet of DS1307..??
if yes then the details regarding storing time is already given there.


by the way according to me, first you need to interface you MCU with LCD and keypad..then only you move to RTC.
have you done above both the interfacing parts..??
may i know which keypad r u using ?

IF YOU REALLY WANT TO LEARN PROGRAMMING THEN KEEP ONE THING ALWAYS IN MIND. DONT USE READYMADE CODE. YA U CAN REFER IT BUT PLEASE AVAOID TO USE IT AS IT IS IN YOU PROGRAM.
 

ds1307 interfacing pic16f877a using ccs

Pieces of program I done to PIC16F877 using CCS version 3.249 :


At declaration :
Code:
////////////////////////////////////////////////////////////////////////
void init_I2C ( void )
{
   output_float( I2C_SCL )     ;
   output_float( I2C_SDA )     ;
}
////////////////////////////////////////////////////////////////////////
int1 i2c_ready ( unsigned int8 address )
{
   int1 ack                    ;
   i2c_start()                 ;  // If the write command is acknowledged,
   ack = i2c_write( address )  ;  // then the device is ready.
   i2c_stop()                  ;
   return ( !ack )             ;
}
////////////////////////////////////////////////////////////////////////
void I2CSendByte ( unsigned int8 Chip , unsigned int8 address , unsigned int8 data_value )
{
///   while ( ! i2c_ready ( address ) ) ;
///   i2c_stop()                  ;
   delay_us   ( 10 )           ;     /* Solucao Empirica       */
	i2c_start()                 ;     /* START CONDITION        */
   i2c_write( Chip | ESCRITA ) ;     /* SLAVE ADDRESS -> WRITE */
   i2c_write( address )        ;     /* WORD ADDRESS           */
   i2c_write( data_value )     ;     /* WRITE DATA             */
	i2c_stop()                  ;     /* STOP CONDITION         */
   delay_ms             ( 50 ) ;     /* Solucao Empirica       */
}

////////////////////////////////////////////////////////////////////////
unsigned int8 I2CGetByte( unsigned int8 Chip , unsigned int8 address )
{
	unsigned int8 data_value                          ;
///   i2c_stop()                                     ;
   delay_us   ( 10 )                                 ;     /* Solucao Empirica       */
   i2c_start()                                       ;     /* START CONDITION        */
   i2c_write( Chip | ESCRITA )                       ;     /* SLAVE ADDRESS -> WRITE */
   if ( Chip == SELECT_LM75A )
      i2c_write( ENDERECO_TEMPERATURA )              ;     /* WORD ADDRESS           */
      else
      i2c_write( address )                           ;     /* WORD ADDRESS           */
   delay_us   ( 10 )                                 ;     /* Solucao Empirica       */
   i2c_start()                                       ;     /* SATRT CONDITION        */
	i2c_write( Chip | LEITURA )                       ;     /* SLAVE ADDRESS -> READ  */
   if ( Chip == SELECT_LM75A )
      {
      TemperaturaDaPlaca   = i2c_read()              ;     /* READ DATA              */
      data_value = (unsigned int8)TemperaturaDaPlaca ;
      TemperaturaDaPlaca <<= 8                       ;
      TemperaturaDaPlaca  |= i2c_read()              ;     /* READ DATA              */
      }
      else
      data_value = i2c_read()                        ;     /* READ DATA              */
	i2c_stop()                                        ;     /* STOP CONDITION         */
   delay_ms             ( 50 )                       ;     /* Solucao Empirica       */
	return( data_value )                              ;
}
////////////////////////////////////////////////////////////////////////
void ds1307_send_byte ( unsigned int8 address, unsigned int8 data_value )
{
I2CSendByte ( SELECT_DS1307 , address , data_value ) ;
}
////////////////////////////////////////////////////////////////////////
unsigned int8 ds1307_get_byte ( unsigned int8 address )
{
unsigned int8 Resposta ;
Resposta = I2CGetByte( SELECT_DS1307 , address ) ;
return ( Resposta ) ;
}
////////////////////////////////////////////////////////////////////////
void ds1307_send_time( void )
{
   delay_us   ( 10 )                      ;     /* Solucao Empirica       */
   i2c_start()                            ;     /* START CONDITION        */
   i2c_write( SELECT_DS1307 | ESCRITA )   ;     /* SLAVE ADDRESS -> WRITE */
   i2c_write( MINUTES )                   ;     /* WORD ADDRESS           */
   i2c_write( Minuto_ds1307_digitos )     ;     /* WRITE DATA             */
   i2c_write( Hora_ds1307_digitos   )     ;     /* WRITE DATA             */
   i2c_write( Semana_ds1307_digitos )     ;     /* WRITE DATA             */
   i2c_write( Dia_ds1307_digitos )        ;     /* WRITE DATA             */
   i2c_write( Mes_ds1307_digitos )        ;     /* WRITE DATA             */
   i2c_write( Ano_ds1307_digitos )        ;     /* WRITE DATA             */
   i2c_stop()                             ;     /* STOP CONDITION         */
   delay_ms  ( 50 )                       ;     /* Solucao Empirica       */
}
////////////////////////////////////////////////////////////////////////
void ds1307_get_time( void )
{
i2c_start()                          ;
i2c_write( SELECT_DS1307 | ESCRITA ) ;
i2c_write( MINUTES )                 ;
i2c_start()                          ;
i2c_write( SELECT_DS1307 | LEITURA ) ;
Minuto_ds1307_digitos = i2c_read()   ;
Hora_ds1307_digitos   = i2c_read()   ;
Semana_ds1307_digitos = i2c_read()   ;
Dia_ds1307_digitos    = i2c_read()   ;
Mes_ds1307_digitos    = i2c_read()   ;
Ano_ds1307_digitos    = i2c_read()   ;
i2c_stop()                           ;
}
////////////////////////////////////////////////////////////////////////



At main program :

Code:
  ds1307_send_byte( CONTROL, CONTROL_WORD );
  ds1307_send_byte( SECONDS ,        ( CH | 0 )                              ) ;
  ds1307_send_byte( MINUTES ,        ( ( MinutoDezena << 4 ) | MinutoUnidade ) ) ;
  ds1307_send_byte( HOURS   ,        ( ( HoraDezena   << 4 ) | HoraUnidade   ) ) ;
  ds1307_send_byte( DAY     ,                         INIT_DAY               ) ;
  ds1307_send_byte( DATE    ,        ( ( DiaDezena   << 4 )  |  DiaUnidade   ) ) ;
  ds1307_send_byte( MONTH   ,        ( ( MesDezena   << 4 )  |  MesUnidade   ) ) ;
  ds1307_send_byte( YEAR    ,        ( ( AnoDezena   << 4 )  |  AnoUnidade   ) ) ;
[/img]
 

interfacing ds1307

i am implementing my project first in simulation only. i am using PROTEUS VSM 7.1, and the KEYPAD-PHONE in that simulator is the one that i'm using.

any other suggestions?

thanks.

Added after 9 minutes:

thank you, andre_teprom,

i will try to implement that code asap and i will tell you the results as soon as i get back.

thanks again.
 

ccs project ds1307

i am implementing my project first in simulation only. i am using PROTEUS VSM 7.1, and the KEYPAD-PHONE in that simulator is the one that i'm using.

YOU MEAN MATRIX KEYPAD.. RIGHT..??

YOU HAVENT ANSWERED MY OTHERE QUES.
PLEASE READ LAST POSTS PROPERLY AND REPLY ME..

THANK YOU..
 

programming the ds1307

H_D_R said:
elizabeth ann said:
wow, very fast reply, thank you.

yes i am storing both the alarm and the clock.

i am using DS1307 with 16F877a, and i am constructing the program in CCS C.

any suggestions? thank you again.

sorry to say but i dont have any experience of 16F877a not even CCS C too.

i am using 89S52 with DS1307 in ASM language.
so i can help you only DS1307 side part. but if you can understand flow then you can implement in your CCS C.
please let me know have u read datasheet of DS1307..??
if yes then the details regarding storing time is already given there.


by the way according to me, first you need to interface you MCU with LCD and keypad..then only you move to RTC.
have you done above both the interfacing parts..??
may i know which keypad r u using ?

IF YOU REALLY WANT TO LEARN PROGRAMMING THEN KEEP ONE THING ALWAYS IN MIND. DONT USE READYMADE CODE. YA U CAN REFER IT BUT PLEASE AVAOID TO USE IT AS IT IS IN YOU PROGRAM.

i won't use any of the codes that will be given to me as they are for reference purposes only. keep it cool, H_D_R. too bad you're much versed in Assembly Language , but thank you for the note. i will remember that well.

cheers!

elizabeth ann
 

ds1307 ccs code

ya I know but for your kind info., i have just started MCU programming.
and however in Embedded C also they are using some part of ASM.
so as per my thoughts its better to get command first on ASM.

that’s why i have decided to get command on ASM first and then C...

by the way, if you want then I’ll help you else i am not interested to waste my important time...
 

16f877a+ds1307+ccs

thanks for your patience, HDR..

well i have been developing my own code right now but any help from everyone else will be very important to the success of this project. to explain our project further, i would be very glad to send you a simple flowchart of how things are going to be done. if you're interested to get this, please just tell me.
by the way, as i have previously mentioned, everything has to be in C language. they say that i have to continuously poll the micro (16f877a) to get time from DS1307. hope that simple info helps. again, about the flowchart, you can help me better if you could have a copy of it. just tell me if you want to. i honestly need help on this.
thank you very much.

elizabeth ann
 

keypad-phone 16f877 ccs

You have to poll DS1307 not PIC16F877A, most compilers have built-in I2C functions making it very easy to code project like yours.
 

ds1307 programming understanding

penoy_balut said:
You have to poll DS1307 not PIC16F877A, most compilers have built-in I2C functions making it very easy to code project like yours.

In fact, but despite several attempts, I could not access this device by PIC built-in hardware with CCS compiler I2C API functions.

+++
 

keypad phone proteus

elizabeth ann said:
thanks for your patience, HDR..

well i have been developing my own code right now but any help from everyone else will be very important to the success of this project. to explain our project further, i would be very glad to send you a simple flowchart of how things are going to be done. if you're interested to get this, please just tell me.
by the way, as i have previously mentioned, everything has to be in C language. they say that i have to continuously poll the micro (16f877a) to get time from DS1307. hope that simple info helps. again, about the flowchart, you can help me better if you could have a copy of it. just tell me if you want to. i honestly need help on this.
thank you very much.

elizabeth ann

okey mail me that copy..
because i also have to look..
so imagination will be more clear...:D
 

i have same problem f u reach to solve tell me
 

guys i'm new here...there's anybody who can help me ..who can give me a sample code of date and time monitoring using DS1307, LCD and 16f877a...pls..sample codes in MPlab IDE, and hi-tech C compiler..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top