- Katılım
- 24 Şubat 2018
- Mesajlar
- 24,143
Şimdi ben de kurdum devreyi.
Test programı şu:
Test programı şu:
C++:
#include <SPI.h>
#define AD9833_CS 10
static double frequency = 120000.0;
void setup()
{
Serial.begin(115200);
pinMode(AD9833_CS, OUTPUT);
digitalWrite(AD9833_CS, HIGH);
SPI.begin();
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE2));
}
void loop()
{
char buffer[100];
unsigned long freq0 = round(frequency * 10.73741824);
snprintf(buffer, sizeof(buffer), "freq0 = %lu\n", freq0);
Serial.print(buffer);
unsigned int freq0_lo = freq0 & 0x3fff;
unsigned int freq0_hi = (freq0 >> 14) & 0x3fff;
snprintf(buffer, sizeof(buffer), "freq0_lo = 0x%04X, freq0_hi = 0x%04X\n", freq0_lo, freq0_hi);
Serial.print(buffer);
digitalWrite(AD9833_CS, LOW);
SPI.transfer16(0x2000);
SPI.transfer16(0x4000 | freq0_lo);
SPI.transfer16(0x4000 | freq0_hi);
digitalWrite(AD9833_CS, HIGH);
while (1)
{
;
}
}