Код:
// Расчет частоты для DDS
// Frequency calc from datasheet page 8 = <sys clock> * <frequency tuning word>/2^32
void sendFrequency(double frequency,double frequency2) {
int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on 9850. You can make 'slight' tuning variations here by adjusting the clock frequency.
int32_t freq = frequency * 4294967295/125000000; // note 125 MHz clock on 9850. You can make 'slight' tuning variations here by adjusting the clock frequency.
for (int b=0; b<4; b++, freq>>=8, freq2>>=8) { tfr_byte(freq & 0xFF,freq2 & 0xFF); }
tfr_byte(0x00,0x00); // Final control byte, all 0 for 9850 chip
pulseHigh(FQ_UD); // Done! Should see output
} // Конец расчета частоты
// Передача частоты в DDS
// transfers a byte, a bit at a time, LSB first to the 9850 via serial DATA line
void tfr_byte(byte data,byte data2)
{
for (int i=0; i<8; i++, data>>=1,data2>>=1)
{
digitalWrite(DATA, data & 0x01);
digitalWrite(DATA2, data2 & 0x01);
pulseHigh(W_CLK); //after each bit sent, CLK is pulsed high
}
} // Конец передачи частоты в DDS
Остальное всё отсюда: http://arduino.ru/forum/proekty/dds-...arduino-ad9850