reemy
Joined: 18 Aug 2007 Posts: 2
|
ds1307 |
Posted: Sat Aug 18, 2007 5:10 pm |
|
|
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 |
|