hello every one,
I am using Arduino UNO with DS1077L by using the i2c protocol, I am getting 16.67Mhz frequency as shown in the code, the maximum oscillator frequency is 66Mhz. I can generate any frequency between (66.6MHz -8.13k Hz) by using the OUT1 output pin of the oscillator (DS1077L).
The problem is;
I want to to make a function like if I send frequency value in the argument of function the corresponding register should set automatically. According to the required frequency among different frequency range (66.6MHz -8.13k Hz).
like
function(freq_value)// freq_value= any value between range of (66.6MHz -8.13k Hz)
{
//the register should be set according to that frequency (register(0x01) and MUX register( 0x02))
}
I am stuck into that, how can I make this function please help me. I will be very grateful to you.
#include <Wire.h>
const int ds_address = 0x58; //DS1077 default address
void setup() {
Wire.begin();
Serial.begin(9600);
//Initialize DS1077
i2c_write(ds_address, 0x02, 0x00, 0x00);
i2c_write(ds_address, 0x01, 0x00, 0x80);
i2c_write(ds_address, 0x0D, 0x08);
i2c_write(ds_address, 0x3F);
}
void loop() {
}
void i2c_write(int device, byte address) {
Wire.beginTransmission(device); //start transmission to device
Wire.write(address); // send register address
Wire.endTransmission(); //end transmission
}
void i2c_write(int device, byte address, byte val1) {
Wire.beginTransmission(device); //start transmission to device
Wire.write(address); // send register address
Wire.write(val1); // send value to write
Wire.endTransmission(); //end transmission
}
void i2c_write(int device, byte address, byte val1, byte val2) {
Wire.beginTransmission(device); //start transmission to device
Wire.write(address); // send register address
Wire.write(val1); // send value to write
Wire.write(val2); // send value to write
Wire.endTransmission(); //end transmission
}