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

another question on time project

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



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

another question on time project
PostPosted: Sat Apr 14, 2007 1:28 pm     Reply with quote

I'm trying to add on more stuff to the time and temp project. I've added a battery back up now, however when I turn the clock off and then on it stays at the same time. This happens because the init function sets registers to the value in the code. A work around for me was to set the time I want in the registers, plug the chip into the project turn on the clock with the battery back up, then take the PIC out reprogram it by commenting out the set_time function.

This takes care of the problem sort of, when I turn the clock on and off the battery will keep the time great, but it won't advance the time until I power the clock back on. Is that clear as mud?

basically I can run the clock. lets say it shows 8:30 then I turn the clock off for ten minutes when I turn the power back on it still says 8:30, but then will start running normally. So does anyone have an idea of how I can get the clock to keep it's time internally while the power project is off,
and then get that out. I know it's somewhere in the clock RAM 08H-3FH
I've tried using some if statements to get it, but no luck really.

Code:

#include <SLED4C_1620a.h> // header file & function prototypes

void Main(void)
{
int announce=0; // holds # of time/temp announcements

init(); // initialize I/O & peripherals

while(1) // loop forever
{
read_time(); // read & display DS1307 time
read_temp(); // read & display DS1620 temp
  }

// DID NOT INCLUDE THE REST OF MAIN NOT RELEVANT

// init calls this function
// set time & date on power-up
void set_time(void)
{
char i;

// put initial date/time into array
ds1307_regs[SECONDS_REG] = 55;// seconds
ds1307_regs[MINUTES_REG] = 59;// minutes
ds1307_regs[HOURS_REG] = 21;// hour
ds1307_regs[DAY_OF_WEEK_REG] = 0; // not used
ds1307_regs[DATE_REG] = 14;// date
ds1307_regs[MONTH_REG] = 07;// month
ds1307_regs[YEAR_REG] = 04;// year

// convert to BCD

for(i=0; i<7; i++)
{
ds1307_regs[i] = toBCD(ds1307_regs[i]);
}

ds1307_regs[SECONDS_REG] &= 0x7f;
ds1307_regs[HOURS_REG] &= 0x3f;

// write 7 bytes of BCD data to ds1307
i2c_start();
i2c_write(WRITE_CNTRL);

// start at seconds register
i2c_write(SECONDS_REG);

// write 7 bytes to registers 0 to 6
for(i=0; i<7; i++)
{
i2c_write(ds1307_regs[i]);
}
i2c_write(CONTROL_INIT_VAL);
i2c_stop();
}

// read time & date from DS1307
void read_time(void)
{
i2c_start();
i2c_write(WRITE_CNTRL);

// start i2c read at seconds register
i2c_write(SECONDS_REG);

i2c_start();
i2c_write(READ_CNTRL);

// read the 7 bytes from the ds1307. Mask off the unused bits
ds1307_regs[SECONDS_REG] = i2c_read() & 0x7f;
ds1307_regs[MINUTES_REG] = i2c_read() & 0x7f;
ds1307_regs[HOURS_REG] = i2c_read() & 0x3f;
ds1307_regs[DAY_OF_WEEK_REG] = i2c_read() & 0x07;
ds1307_regs[DATE_REG] = i2c_read() & 0x3f;
ds1307_regs[MONTH_REG] = i2c_read() & 0x1f;
ds1307_regs[YEAR_REG] = i2c_read(0);

i2c_stop();

stuff from SLED4C_1620a.h file

// DS1307 control bytes
#define WRITE_CNTRL 0xd0
#define READ_CNTRL 0xd1

// DS1307 register offsets
#define SECONDS_REG 0
#define MINUTES_REG 1
#define HOURS_REG 2
#define DAY_OF_WEEK_REG 3
#define DATE_REG 4
#define MONTH_REG 5
#define YEAR_REG 6
#define CONTROL_REG 7
#define DATE_TIME_BYTE_COUNT 7
#define DS1307_NVRAM_START_ADDR 8
#define CONTROL_INIT_VAL 0x80


Another question is what do these commands do? Why are they needed instead of just using the time specified times in the program?

#define DS1307_NVRAM_START_ADDR 8
#define CONTROL_INIT_VAL 0x80

And finally looking at the code where they mask off the unused bits the values they are using don't seem to match in the data sheet where do they get them?

// read the 7 bytes from the ds1307. Mask off the unused bits
ds1307_regs[SECONDS_REG] = i2c_read() & 0x7f;
ds1307_regs[MINUTES_REG] = i2c_read() & 0x7f;
ds1307_regs[HOURS_REG] = i2c_read() & 0x3f;
ds1307_regs[DAY_OF_WEEK_REG] = i2c_read() & 0x07;
ds1307_regs[DATE_REG] = i2c_read() & 0x3f;
ds1307_regs[MONTH_REG] = i2c_read() & 0x1f;
ds1307_regs[YEAR_REG] = i2c_read(0);



but the data sheet says the address of the seconds register is 00H, but bit 7 has to be 0 to keep the oscillator running all these lines are saying they are masking off bits just kind of confusing me. Thanks for the help I know I'm asking a lot here.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sat Apr 14, 2007 3:41 pm     Reply with quote

It sounds like the CH (clock halt) bit isn't getting set to 0 in your init function... Where is your ds1307 init function?

Quote:
Another question is what do these commands do? Why are they needed instead of just using the time specified times in the program?

#define DS1307_NVRAM_START_ADDR 8
#define CONTROL_INIT_VAL 0x80


Use the search function to see where they are called and see what they do. If they're not called then they do nothing....

DS1307_NVRAM_START_ADDR is the offset to where the RAM is. (No your problem isn't there.... The RAM is just for storing stuff that may be needed between runs of the PIC. You shouldn't be concerned with this.

CONTROL_INIT_VAL is the value to be written to the control register. Use your Windows calculator in scientific mode and convert 0x80 to binary and see what registers are 1s and 0s when the control register is init'd.

The masking that is happening is a way of only updating the bits in a byte that you are interested in. Find a truth table for a logical AND and try to figure out what is happening in those statements.

What type of battery are you using?

After you post your DS1307 init function it should be easy to find the problem....

John
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Sat Apr 14, 2007 5:36 pm     Reply with quote

hi John

here is the entire program code from Rentron's website

Code:

File name: SLED4C_1620a.c

Talking time & temp with display of time & temperature on the
SLED4C serial LED display module. Uses the DS1620 temp sensor,
DS1307 RTC, and EMIC text-to-speech module

When the temperature >= the high alarm setpoint, display the OUCH
message. Below setpoint, display the temp normally with voice
updates of time & temp on every hour.

MAX temperature range is from 0 to 99

*/

#include <SLED4C_1620a.h>          // header file & function prototypes

void Main(void)
{
   int announce=0;                 // holds # of time/temp announcements

   init();                         // initialize I/O & peripherals

   while(1)                        // loop forever
   {
     read_time();                  // read & display DS1307 time
     read_temp();                  // read & display DS1620 temp

     // announce time/temp on roll-over from 59 to 00 minutes
     if(ds1307_regs[MINUTES_REG]==0x00)
     {
       if(!announce)               // say time & temp only if announce=0
       {
         say_time();               // say the current time
         delay_ms(3000);           // delay 3 seconds
         say_temp();               // say the current temperature
         announce +=1;             // increment announcement counts
       }
     }

     if(!ds1307_regs[MINUTES_REG]==0x00)
        announce=0;                // clear announcements until it's time
   }
}

// initialize hardware
void init(void)
{
   port_b_pullups(FALSE);          // portb internal pull-ups off
   setup_comparator(NC_NC_NC_NC);  // all comparators = off
   disable();                      // SLED4C enable pin must idle high
   output_bit(CLK,0);              // SLED4C clock pin must idle low
   disable_interrupts(GLOBAL);     // global interrupts off
   setup_EMIC(2,1);                // set EMIC volume 0=low 7=max & pitch
 [b]  set_time();                     // set ds1307 time on power-up[/b]
   init_1620();                    // inititialize DS1620 temp sensor
   setpoint=0x85;                  // set high temp alarm setpoint here
}

// shift out 8-bits in DAT MSB first
void send_byte(int DAT)
{
   int n;
   for(n=0; n<8; n++)              // loop for 8-bits total
   {
     output_bit(DOUT,DAT & 0x80);  // output MSB of 8-bit value
     output_bit(CLK, 1);           // clock pin = 1
     output_bit(CLK, 0);           // clock pin = 0
     DAT = DAT << 1;               // shift lower bits left into MSB of byte
   }
}

// shift out low nibble in NIB MSB first
void send_nib(int NIB)
{
   int n;
   for(n=0; n<4; n++)              // loop for 4-bits total
   {
     output_bit(DOUT,NIB & 0x08);  // output MSB of 4-bit value
     output_bit(CLK, 1);           // clock pin = 1
     output_bit(CLK, 0);           // clock pin = 0
     NIB = NIB << 1;               // shift lower bits left into MSB of nibble
   }
}

// take SLED4C enable pin low
void enable(void)
{
   output_bit(EN,0);               // this enables data entry into SLED4C
}                                  // onboard config & data display registers

// take SLED4C enable pin high
void disable(void)
{
   output_bit(EN,1);               // this transfers data to the SLED4C internal
}                                  // registers then disables further data entry

// write a byte to the DS1620
void write_1620(byte cmd)
{
   byte i;

   for(i=0; i<8; i++)
   {
     output_low(CLKD);
     output_bit(DQ, shift_right(&cmd,1,0));
     output_high(CLKD);
   }
}

// initialize the DS1620
void init_1620(void)
{
   // set CLK and RST to correct states
   output_high(CLKD);
   delay_us(2);
   output_low(RST);

   // set DS1620 config to continuous convert
   // and CPU communications mode
   output_high(RST);
   write_1620(0x0C);           // send Write Config command
   write_1620(0x02);           // configure for CPU mode, continuous convert
   output_low(RST);

   // start conversion
   output_high(RST);
   write_1620(0xEE);           // send Start Convert command
   output_low(RST);
}

// read & display temperature from DS1620.
void read_temp(void)
{
   byte i;

   output_high(RST);
   write_1620(0xAA);          // send Read Temp command

   temp_data = 0;             // clear temp_data on entry

   for(i=0; i<9; i++)         // loop for 9-bits
   {
     output_low(CLKD);
     temp_data = temp_data >> 1;
     if (input(DQ))
     {
        temp_data = temp_data | 0x100;
     }
     output_high(CLKD);
   }

   temp_data = temp_data/2;      // convert temp_data to whole deg C

   output_low(RST);

   convert();                    // convert C to F then to BCD

   if (temp_r >= setpoint)       // if temp >= setpoint display OUCH
   {
      ouch();                    // call OUCH function if temp >= high setpt
      return;                    // do not update temp display when temp >= setpt
   }

   enable();                     // enable SLED4C data entry
   send_byte(0b11001011);        // digits 5,4,2 HEX decode. Digits 3,1 special
   disable();                    // write config value into config register

   delay_ms(1);                  // short pause between config & display reg write

   enable();                     // enable SLED4C data entry
   send_nib(0x00);               // DIM display + DP's off
   send_byte(temp_r);            // display temp on digits 5/4
   send_byte(0xFF);              // display Deg F on digits 3/2
   send_nib(0x00);               // turn colon off
   disable();                    // write data into display registers
   delay_ms(2000);               // wait 2 seonds between temp & time updates
}

// convert temp from deg C to deg F, then pass
// to BCD conversion conversion function
void convert(void)
{
   temp_data = (temp_data * 9/5)+32; // convert C to F
   temp_r = toBCD(temp_data);        // convert to BCD for display
}

// display OUCH when temp >= high alarm setpoint
void ouch(void)
{
   int y = 8, n;

   enable();                     // enable data entry
   send_byte(0b11010111);        // digits 5,3 hex decode. 4,2,1 special
   disable();                    // write config data into config register

   for(n=0; n<8; n++)            // execute ouch display function 8 times
   {
      y ^= 8;                    // toggle y.bit.3
      enable();                  // enable SLED4C data entry
      send_nib(y);               // toggle DIM & BRIGHT, no DP's
      send_byte(0x0A);           // display OU on digits 5/4
      send_byte(0xC2);           // display CH on digits 3/2

      send_nib(0x00);            // turn colon off
      disable();                 // write display data into display registers
      delay_ms(250);             // set display "blink loop" delay time in mS
   }
}

// this function converts an 8 bit binary value
// to an 8 bit BCD value. Input range from 0 to 99.

char toBCD(char bin_val)
{
   char temp;
   char retval;

   temp = bin_val;
   retval = 0;

   while(1)
   {
   // get tens digit by multiple subtraction
   // of 10 from bin_val
      if(temp >= 10)
      {
         temp -= 10;
         retval += 0x10; // increment tens digit
      }
         else            // get ones digit by adding remainder
      {
         retval += temp; // adjusted result
         break;
      }
   }
         return(retval);
}

// set time & date on power-up
void set_time(void)
{
   char i;

   // put initial date/time into array
   ds1307_regs[SECONDS_REG]     = 55;// seconds
   ds1307_regs[MINUTES_REG]     = 59;// minutes
   ds1307_regs[HOURS_REG]       = 21;// hour
   ds1307_regs[DAY_OF_WEEK_REG] = 0; // not used
   ds1307_regs[DATE_REG]        = 14;// date
   ds1307_regs[MONTH_REG]       = 07;// month
   ds1307_regs[YEAR_REG]        = 04;// year

   // convert to BCD

   for(i=0; i<7; i++)
   {
      ds1307_regs[i] = toBCD(ds1307_regs[i]);
   }

   ds1307_regs[SECONDS_REG] &= 0x7f;
   ds1307_regs[HOURS_REG] &= 0x3f;

   // write 7 bytes of BCD data to ds1307
   i2c_start();
   i2c_write(WRITE_CNTRL);

   // start at seconds register
   i2c_write(SECONDS_REG);

   // write 7 bytes to registers 0 to 6
   for(i=0; i<7; i++)
   {
      i2c_write(ds1307_regs[i]);
   }
   i2c_write(CONTROL_INIT_VAL);
   i2c_stop();
}

// read time & date from DS1307
void read_time(void)
{
   i2c_start();
   i2c_write(WRITE_CNTRL);

   // start i2c read at seconds register
   i2c_write(SECONDS_REG);

   i2c_start();
   i2c_write(READ_CNTRL);

   // read the 7 bytes from the ds1307. Mask off the unused bits
   ds1307_regs[SECONDS_REG]     = i2c_read() & 0x7f;
   ds1307_regs[MINUTES_REG]     = i2c_read() & 0x7f;
   ds1307_regs[HOURS_REG]       = i2c_read() & 0x3f;
   ds1307_regs[DAY_OF_WEEK_REG] = i2c_read() & 0x07;
   ds1307_regs[DATE_REG]        = i2c_read() & 0x3f;
   ds1307_regs[MONTH_REG]       = i2c_read() & 0x1f;
   ds1307_regs[YEAR_REG]        = i2c_read(0);

   i2c_stop();

   enable();                     // enable SLED4C data entry
   send_byte(0b11000001);        // all banks HEX decode
   disable();                    // write config value into config register

   enable();                     // enable SLED4C data entry
   send_nib(0x00);               // DIM display + DP's off
   send_byte(ds1307_regs[HOURS_REG]);   // display hour on banks 5/4
   send_byte(ds1307_regs[MINUTES_REG]); // display minutes on banks 3/2

   send_nib(0x02);               // turn colon on
   disable();                    // write data into display registers
   delay_ms(2000);               // wait 2 seconds between temp & time updates
}

// say the time
void say_time(void)
{
   printf("say=the time iz %X  %X;",ds1307_regs[HOURS_REG],ds1307_regs[MINUTES_REG]);
   delay_ms(2000);          // allow time for message to play
}                           // adjust as required for message length

// say the temperature
void say_temp(void)
{
   printf("say=the temperature iz %Ld degrees faren hyte;",temp_data);
   delay_ms(2000);          // allow time for message to play
}                           // adjust as required for message length

// initialize EMIC module & set volume + pitch
void setup_EMIC(int vol, int pitch)
{
   output_bit(EM_Rst,0);     // hard reset the EMIC module
   delay_us(200);            // wait a minimum of 100uS
   output_float(EM_Rst);     // float reset output to release
   delay_ms(1000);           // wait for EMIC OK response before proceeding
   printf("volume=%d;",vol); // send volume setting
   delay_ms(1000);           // wait for EMIC OK response before proceeding
   printf("pitch=%d;",pitch);
   delay_ms(1000);
}



The Header File:
/*
File name: SLED4C_1620a.h
Header file for SLED4C_1620a.c

*/

#include <16f876A.h>
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_C0)
#use i2c(Master, SDA=PIN_B0, SCL=PIN_B1)


// Define DS1620 interface pins
#define DQ PIN_B2     // Wire rb2 to pin #1 on DS1620
#define CLKD PIN_B3   // Wire rb3 to pin #2 on DS1620
#define RST PIN_B4    // Wire rb4 to pin #3 on DS1620

// Define SLED4C interface pins
#define EN PIN_B5     // Wire rb5 to enable pin #5 on SLED4C
#define CLK PIN_B6    // Wire rb6 to clock pin #4 on SLED4C
#define DOUT PIN_B7   // Wire rb7 to data pin #3 on SLED4C

// DS1307 control bytes
#define WRITE_CNTRL 0xd0
#define READ_CNTRL 0xd1

// DS1307 register offsets
#define SECONDS_REG 0
#define MINUTES_REG 1
#define HOURS_REG 2
#define DAY_OF_WEEK_REG 3
#define DATE_REG 4
#define MONTH_REG 5
#define YEAR_REG 6
#define CONTROL_REG 7
#define DATE_TIME_BYTE_COUNT 7
#define DS1307_NVRAM_START_ADDR 8
#define CONTROL_INIT_VAL 0x80

// EMIC text to speech constants
#define EM_Rst PIN_C1       // EMIC voice module reset pin #14


// Global vars
signed long temp_data;      // raw temp
int8 temp_r;                // final BCD temp result
int setpoint;               // high temp setpoint

// PIC I/O & peripheral init function prototype
void init(void);            // PIC port & peripheral initialization

// SLED4C serial display function Prototypes
void send_byte(int DAT);    // send byte value to SLED4C
void send_nib(int NIB);     // send nibble value to SLED4C
void enable(void);          // enable data entry into SLED4C registers
void disable(void);         // write data into SLED4C registers & disable

// DS1620 & temp related function prototypes
void write_1620(byte cmd);  // write to DS1620
void init_1620(void);       // initialize DS1620
void read_temp(void);       // read temp from DS1620
void convert(void);         // convert C to F then to BCD for display
void ouch(void);            // display OUCH when >= high temp setpoint
char toBCD(char bin_val);   // conversion to BCD

// DS1307 function prototypes
void set_time(void);
void read_time(void);
char read_byte(char addr);
void write_byte(char addr, char value);

//EMIC text-to-speech module function prototypes
void say_time(void);
void say_temp(void);
void setup_EMIC(int vol, int pitch);

int ds1307_regs[DATE_TIME_BYTE_COUNT];



as you can see all the registers are defined in the .h file, The main calls the init function, which then calls several other functions. including set_time, when the time is set it isn't referenced again, instead read_time is which is my where my problem lies. I need to somehow get that information that the battery backup stores in the DS1307 RAM into the PIC when I turn VCC back on.


I tried using an if statement to get it to work but was unsuccessful, I deleted that build so I don't have it anymore, psudocode of it though was
something like

in the init function above

if ds1307_regs[SECONDS_REG] == 0x7f
{
read_time
}
else set_time

that totally flopped though
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Sat Apr 14, 2007 8:12 pm     Reply with quote

What I would really like to do is test this program on the MPLAB simulator, but I have no clue how I would even go about it. I've tried reading the manual and looking at the examples but they are somewhat confusing.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 12:52 am     Reply with quote

What type of back-up battery are you using?

You should be able to program your PIC with the code as you have it. Every time you re-apply power or restart the PIC it is, obviously, going to reset the time to what ever you have written in your code. To handle this, just update your time in your code to something in the near future, program your PIC, and then power it up at the time you have programmed in your code. Recompile the code with the set_time() line commented out of the init function. Reprogram the PIC with the new code and the ds1307 should still be keeping time from your initial programming (that is if you have the correct battery connected correctly.)

Quote:
instead read_time is which is my where my problem lies.


I think your problem lies with either the incorrect battery or your misunderstanding of how to get the time set in the ds1307 and then not change it with future resets.

Quote:
I need to somehow get that information that the battery backup stores in the DS1307 RAM into the PIC when I turn VCC back on.


No, nothing gets stored in the RAM unless you put it there. The RAM is for program data that you want the ds1307 to hold between power applications NOT for time information. The ds1307 will merrily keep on clicking away and keeping time once the CH register is set to 0 and power is applied (either Vdd or Vbackup.)

So, to solve your problem, you need to:

Use the correct battery (a 3V lithium).

Get the time set and CH register set to 0 (you do this with the code that you have posted.)

Reprogram the PIC to NOT reset the time with each reset.

Good luck,

John
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 7:59 am     Reply with quote

Thanks for your responses,

The battery I'm using is a 3 volt lithium battery, I've tested it and it's putting about about 2.8 volts right now, and it is keeping time great.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 8:26 am     Reply with quote

Quote:
it is keeping time great.


Can you clarify what the problem is, and exactly what you do to get that to happen?

From your previous explanation it sounded as though the ds1307 wouldn't keep time if you commented out set_time().

John
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 9:12 am     Reply with quote

The DS1307 keeps time good when the power is on for the entire circuit.

When I turn the power off the backup battery keeps the time the clock was at just when it was turned off. I have the program set per your directions

so for example

a. I turn on the clock it's 21:59
b. wait for about ten minutes clock says 22:09
b. turn off the clock (it's now on battery backup)
c. reprogram the PIC real quick to comment out set_time function
d. plug PIC back into circuit and turn it on
e. clock says 22:09 so I know the battery backup is working
f. run the clock for another 10 minutes time says 22:19
g. turn off the clock for ten minutes time should be 22:29 when I turn it on
but it still says 22:19

That last part is where I'm having difficulty
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 10:25 am     Reply with quote

Only thing I can think of just now is to do "h." for me and tell me what happens.


Do all your a-g items again.
c. & d. No hurry here. Take a few minutes and see if that changes the out come.

h. Wait ten minutes and see if it increments to 22:19 from 22:29 (i.e. make sure the clock really is running on the second power-up.)

What sort of power supply are you using? Do you have large Caps on the board? (I'm wondering if the Caps are some how powering the ds1307 instead of the backup battery... and giving erroneous indications of what's happening?) How do you remove power from the circuit, a switch, pull a power connector?

I would tend to default to a known good ds1307 driver to see if it is a software or hardware problem. There are several in the code library. I've never had problems with the ds1307 when using the CCS or other folk's drivers.

What you should really do is stop chasing your tail here and write a simple test program using a good ds1307 driver to confirm the RTC's correct operation. Trust me, the time it will take to write that code will most likely be a lot less than buggering around with some one else's code. I tend to procrastinate and avoid low level debugging like that too, but I always am relieved when I do it and the problem pops right out at me. It will also get you into the driver code and help you understand what's going on.

Try this one:

http://www.ccsinfo.com/forum/viewtopic.php?t=23255


John
mcnscott2



Joined: 25 Mar 2007
Posts: 19

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 11:47 am     Reply with quote

John

Your note about the capacitor gave me an idea and I did a bit of research I aways put a .1uF cap between ground and an IC well you can't do this with the DS1307. When I turned the power off the energy from the battery back to the cap was causing power to to bounce back and forth between the cap and the battery, not causing the oscillator to operate. I took out the cap hooked to the DS1307 and problem solved!

Scott
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Sun Apr 15, 2007 12:08 pm     Reply with quote

Scott,

Didn't quite understand your original and final configuration...

Original (problem):

Vdd-->0.1uFcap(to gnd)-->ds1307Vcc

And...

+3V Lithium---> 0.1uFcap(to gnd)-->ds1307Vbat



Final (operates normally):

Vdd-->0.1uFcap(to gnd)-->ds1307Vcc

And

+3V Lithium-->ds1307Vbat


I've never had problems with decoupling caps on the supply pins. I've never put them on the battery backups.

John
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