Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

DS1307 BOB square wave output
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DS1307 BOB square wave output

by joe61 on Sat Sep 22, 2012 9:15 am

I can't seem to get the square wave output to work. I've checked the data sheet for both the processor and the DS1307, and I'm pretty sure I have things setup right. I've measured the square wave output pin on the board, but don't see any changes. Are there any known problems with this that might have a workaround? This is the second board I've tried.

I'm using an ATmega8535 with Peter Fleury's I2C library and avr-gcc. Here's the code where I setup the square wave. Please slap me upside the head if I need it. Thanks

Code: Select all | TOGGLE FULL SIZE
static void setupSquareWave ()
{
    // This turns on the square wave output on the DS1307. When the
    // line goes high, it runs into the external interrupt ISR, which
    // sets a flag for the main loop

#if defined(_AVR_IOM1284P_H_) || defined(_AVR_IOM32U4_H_)
    EICRA = (1 <<ISC01) | (1 << ISC01);
    EIMSK = (1 << INT0);
#else
    GICR  |= (1 << INT0);
    MCUCR |= (1 << ISC01) | (1 << ISC00); // trigger on rising edge
#endif

    sei ();

    int ret = i2c_start (DS1307_ADDR + I2C_WRITE);
    if (ret)
    {
        sprintf (buf, "START err: %d\n", ret);
            twiError ("START err 0\n");
    }

    i2c_write (DS1307_CTRL);
    i2c_write (0b00010000);
    i2c_stop ();
}

joe61
 
Posts: 18
Joined: Thu Apr 07, 2011 6:48 pm

Please be positive and constructive with your questions and comments.