Using a control word found in sample code from here to set the si570 to 14.200MHz, I ripped up some code real quick to do it and was astonished and pumped when I saw the frequency meter on my DMM jump to 14.20 MHz upon reflashing my launchpad.
Here is the code that worked when I compiled it:
#include <msp430.h>#include "serial.h" #include "i2c.h" void msprintf(char *format, ...); void main(void) { char c; char dev_address = 0xAA; int i; // Disable watchdog WDTCTL = WDTPW + WDTHOLD; // Use 1 MHz DCO factory calibration DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // Setup the serial port // Serial out: P1.1 (BIT1) // Serial in: P1.2 (BIT2) // Bit rate: 9600 (CPU freq / bit rate) serial_setup (BIT1, BIT2, 1000000 / 9600); msprintf("serial is working...\r\n"); char err; char i2cWriteBuf[] = {0, 0, 0, 0, 0, 0}; int j; // Hard reset of frequency to 14.2 MHz i2cWriteBuf[0]=0xA9 ; i2cWriteBuf[1]=0xC2; i2cWriteBuf[2]=0xA8 ; i2cWriteBuf[3]=0x7C ; i2cWriteBuf[4]=0x5D ; i2cWriteBuf[5]=0x39; kpprintf("14.2 MHz\r\n"); msprintf("init i2c...\r\n"); i2c_init(); __delay_cycles(20000); //Freeze DCO msprintf("Freeze DCO...\r\n"); u8 buf; buf = 0b00010000; i2c_tx(1, dev_address, &buf, 0, 137); msprintf("Write buffer...\r\n"); for (i = 0; i < 6 ; ++i) { i2c_tx(1, dev_address, i2cWriteBuf, 0, i+8); } //Unfreeze DCO msprintf("Unfreeze DCO...\r\n"); buf = 0; i2c_tx(1, dev_address, &buf, 0, 137); msprintf("Read input from serial...\r\n"); for (;;) { // Do forever c = serial_getc (); // Get a char serial_putc (c); // Echo it back } }
So this was strictly a prototype to see if I could at least get the SI570 controlled with a brute force large frequency jump. Next step is to actually create a little library that I can use to control the si570. I found a great integer based source code example that allowed doing the 38-bit math required in some of the calculations here. Adapting it to pass in a structure (so multiple si570s could be controlled), I hope to get this wrapped up pretty soon.
http://www.henriquegravina.net/pu3ike/si570/