Arduino DS1307 Real Time Clock Square Wave Generator

preview_player
Показать описание
Using an Arduino to set square wave frequencies on the SQWOut pin of the DS1307 real time clock chip.

Arduino sketch:

#include "Wire.h"
#include "Time.h"

#define DS1307_I2C_ADDRESS 0x68

// 00010000 to produce a 1 Hz square wave
// from the SQW pin. 00010011 for 32.768 kHz.
// 00010001 for 4.096 kHz. and 00010010 for
// 8.192 kHz. The square wave output
// can be viewed on an oscilloscope.
byte ctrlRegBytes[] = {B00010000, B00010001, B00010010, B00010011};
int freqIdx = 3;

void setup()
{

initFreqDs1307();
}

void loop()
{

}

// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/10*16) + (val%10) );
}

void initFreqDs1307()
{



setFreqDs1307();
}

void setFreqDs1307()
{
byte ctrlRegByte = ctrlRegBytes[freqIdx];


}
Рекомендации по теме
Комментарии
Автор

Useful video to confirm the wave output I should be getting from my DS1307. It looks nice and clean on yours, but at 32khz mine is a rolling 'round topped wave'. Now I'm not sure if it is the home built scope I am using rather than the rtc. thanks. :)

digitaldave