CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ds1307

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
reemy



Joined: 18 Aug 2007
Posts: 2

View user's profile Send private message

ds1307
PostPosted: Sat Aug 18, 2007 5:10 pm     Reply with quote

hi
i'm new
i have exotic problem
i have rtc code using ds1307 on this page http://www.sixca.com/micro/pic/ds1307/

and here is my code

Code:


#include <18f4620.h>
#include <stdlib.h>
#fuses xt,NOWDT,NOLVP
#use delay(clock=4000000)
#include <ds1307>
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7,ERRORS)
#include <INPUT>
.
.
.
.
.
.
.


void main()
   {

   delay_ms(50);
   init_ds1307();          // initial DS1307
   sec=read_ds1307(0);
   write_ds1307(0,sec & 0x7F); // enable oscillator(bit 7 =0)


   write_ds1307(0,0x50); //sec
   write_ds1307(1,0x00); //min
   write_ds1307(2,0x01); //hr
   write_ds1307(3,0x01); //day
   write_ds1307(4,0x01); //date
   write_ds1307(5,0x01); //mnth
   write_ds1307(6,0x01); //year


  enable_interrupts(GLOBAL);
   enable_interrupts(INT_RDA);
   ring_flag=0;
   //on_flag=0;
   f=0;

   while(1) {
//     value= read_eeprom(f);
//     printf("%X\r\n",value);
//     delay_ms(1000);


//value= (f%2);
//printf("%u\r\n",value);
//delay_ms(1000);
//     f++;

start:
    on_flag=1;
   while(on_flag==1){
      //if (clk_flag==1){
      //}
      dow = read_ds1307(3);   //Determine the daya of the week
      Add1=(dow-1)*36+1;      //Start address equation due to dow
      Add2=dow*36;
// printf("%u\r\n",dow);
//delay_ms(1000);
// printf("add1%u\r\n",Add1);
//delay_ms(1000);
// printf("add2%u\r\n",Add2);
//delay_ms(1000);

     hr_eeprom = read_eeprom(Add1);
 //    printf("hr_eeprom%x\r\n",hr_eeprom);
 //     delay_ms(1000);
 //     if (hr_eeprom==25)
 //     {
 //        delay_ms(1000);
 //        goto START;
 //     }  //end if
 //     else
 //     {
         hr = read_ds1307(2);    //Read the current hour
         min = read_ds1307(1);   //Read the current minute

        // if(min!=prev_min)
        // ring_flag=0;



       for (i=Add1;i<Add2;i+=2)
         {
            j = i + 1;
            hr_eeprom= read_eeprom(i);
            min_eeprom = read_eeprom(j);
           //printf("hr_eeprom%x\r\n",hr_eeprom);
           // delay_ms(1000);
           // printf("min_eeprom%x\r\n",min_eeprom);
           // delay_ms(1000);
            if (hr_eeprom==hr)
            {
               if( (min_eeprom == min) )
               {
                 // ring(duration);
                 // min_ring = min_eeprom;
                 output_high(PIN_B0);
                 delay_ms(1000);
                 output_low(PIN_B0);
                 prev_min=min;
                 ring_flag=1;
                  goto START;


               } //if( (min_eeprom == min)&& (flag==0) )
               //delay_ms(500);
            }//if (hr_eeprom==hr)
         }  //end for

      //}  //end else




   }//on_flag

   }//while
   }//main



of course i have my declaration and use of int_rda to get data and save them in eeprom.
i do simulation using Proteus isis simulator and make sure that i get data correct and save them correct but problem occur in compare loop,simulation program cpu load is 93% and is very slowly and i cant see any simulation.why?is this problem in my code?i try to re install both Proteus and ccs compiler and still as it. it make normal simulation for one time and unfortunately i do it just for one byte of data its work fine but this dose not mean its will work for a block of data (i.e.100 byte and more)

regards,
reemy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 19, 2007 2:05 pm     Reply with quote

Quote:

I do simulation using Proteus isis simulator and make sure that i get
data correct and save them correct but problem occur in compare loop,
simulation program cpu load is 93% and is very slowly and i cant see
any simulation.

If Proteus isn't simulating correctly, you should ask about it on the
Proteus forum at the link below:
http://support.labcenter.co.uk/forum/
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group