Maxim DS1077 EconOscillator/Divider Library

Maxim DS1077 EconOscillator/Divider

This class wraps the functions of the DS1077 oscillator into a usable class for mBed. The oscillator uses I2C to communicate with the host MCU. This oscillator output a square wave, so if you're looking for a sine wave - this isn't it.

Be sure to download the DATASHEET (You'll need it to work with this chip). You can also purchase a breakout board from SparkFun. Be sure to ground the CTRL1 and CTRL0 pins if you don't plan on using them.

This library was created using the mbed NXP LPC11U24. Pins p27 and p28 were used for the I2C functions. Be sure to install 1K pull-up resistors on both lines.

Here's the output from the OUT1 pin on my scope after running the sample code below:

/media/uploads/sophtware/ds1077-32khz.png

Below is some sample code that sets the oscillator OUT2 pin to 16.67MHz and the OUT1 pin to 32kHz. It then outputs the content of all the control registers. You'll need the serial debug setup for your mBed. If you still need the serial driver for your mbed, you can get it here.

Sample Code

#include "mbed.h"
#include "DS1077.h"

I2C i2c(p28, p27);       // sda, scl

// Comment out all of the references to 'pc' on this page if you don't have the 
// serial debug driver for your mbed board installed on your computer. If you do,
// I personally like to use Putty as the terminal window to capture debug messages.
Serial pc(USBTX, USBRX); // tx, rx

// Again, remove the '&pc' parameter if you're not debugging.
DS1077 osc(&i2c, &pc);

DigitalOut myled(LED1);

int main() 
{
    pc.printf("** DS1077 EconOscillator **\r\n");

    osc.setSelect();
    wait_ms(1);
    // Set OUT2 to ~16.67MHz
    osc.setPrescalerP0Divisor(DS1077::X8);
    wait_ms(1);
    // Set OUT1 to ~32kHz
    osc.setPrescalerP1Divisor(DS1077::X4);
    wait_ms(1);
    osc.setDivisor(0xFFF);
    wait_ms(1);

    pc.printf("DIV: 0x%X\r\n", osc.divRegister()&0x0000FFFF);
    wait_ms(1);
    pc.printf("MUX: 0x%X\r\n", osc.muxRegister()&0x0000FFFF);
    wait_ms(1);
    pc.printf("BUS: 0x%X\r\n", osc.busRegister());

//    osc.write();

    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

Files at this revision

API Documentation at this revision

Comitter:
sophtware
Date:
Sun Apr 06 16:50:53 2014 +0000
Parent:
1:162fd9241279
Commit message:
Initial Publish

Changed in this revision

DS1077.h Show annotated file Show diff for this revision Revisions of this file
diff -r 162fd9241279 -r 86284a0a46ca DS1077.h
--- a/DS1077.h	Sun Apr 06 16:46:55 2014 +0000
+++ b/DS1077.h	Sun Apr 06 16:50:53 2014 +0000
@@ -25,6 +25,8 @@
 #define CMD_BUS 0x0D
 #define CMD_E2  0x3F
 
+//! Maxim DS1077 EconOscillator/Divider Library
+//! This class wraps the function in the DS1077 oscillator.
 class DS1077
 {
 public: