Ja genau.
Das wird schon funktionieren, irgendwas stimmt eben noch nicht. Ich mach mir da nochmal Gedanken, im Moment komme ich aber leider nicht dazu.
Hi Dirk,
kein Stress... eilt nicht....
hab' gerade dem AD5850 mit dem Weller gedroht......was für ein Gefrickel.... es scheint nun zu funktionieren......
nur ist die Frequenz doppelt so groß wie die Sollfrequenz..... da hängts wohl noch an der Bitschupserei......
So jetzt aber.....
CodeBox C
#include <avr/io.h>
#define F_CPU 1000000UL // 1 MHz
#include <util/delay.h>
#include <avr/interrupt.h>
#define AD9850_PORT PORTC
#define AD9850_DIR DDRC
#define AD9850_DATA PC0 // Gelb - connect to serial data load pin (DATA)
#define AD9850_CLK PC1 // Orange - connect to AD9850 module word load clock pin (CLK)
#define AD9850_FQ_UD PC2 // Grün - connect to freq update pin (FQ)
#define AD9850_RESET PC3 // Blau
#define AD9850_IR PC4 // Braun
#define DDS_CLOCK 125000000
void AD9850_Init (void);
void AD9850_SendByte (uint8_t data);
void AD9850_SendFrequency (uint32_t freq);
int32_t frequency;
void AD9850_wait(void)
{
_delay_us(5);
}
void AD9850_Init (void)
{
// CLK, FQ_UD, RESET, DATA: Low
// CLK, FQ_UD, RESET, DATA: Output
AD9850_PORT &= ~((1<<AD9850_CLK) | (1<<AD9850_FQ_UD) | (1<<AD9850_RESET) | (1<<AD9850_DATA));
AD9850_DIR |= (1<<AD9850_CLK) | (1<<AD9850_FQ_UD) | (1<<AD9850_RESET) | (1<<AD9850_DATA);
AD9850_wait();
// Reset Pulse
AD9850_PORT |= (1<<AD9850_RESET);
AD9850_wait();
AD9850_PORT &= ~(1<<AD9850_RESET);
AD9850_wait();
// CLK Pulse
AD9850_PORT |= (1<<AD9850_CLK);
AD9850_wait();
AD9850_PORT &= ~(1<<AD9850_CLK);
AD9850_wait();
// FQ_UD Pulse
AD9850_PORT |= (1<<AD9850_FQ_UD); // Enable serial mode
AD9850_wait();
AD9850_PORT &= ~(1<<AD9850_FQ_UD);
AD9850_wait();
}
void AD9850_SendFrequency(uint32_t freq)
{
// 32Bit Frequency
AD9850_SendByte((uint8_t) freq);
AD9850_SendByte((uint8_t) (freq>>8));
AD9850_SendByte((uint8_t) (freq>>16));
AD9850_SendByte((uint8_t) (freq>>24));
AD9850_SendByte((uint8_t) (0b00000000));
// 8Bit Control, PowerDown, Phase
AD9850_wait();
// FQ_UD Pulse: Update
AD9850_PORT |= (1<<AD9850_FQ_UD);
AD9850_wait();
AD9850_PORT &= ~(1<<AD9850_FQ_UD);
AD9850_wait();
}
void AD9850_SendByte (uint8_t data)
{
uint8_t i = 8;
do
{
if (data & 1)
{
AD9850_PORT |= (1<<AD9850_DATA); // Data high
} else {
AD9850_PORT &= ~(1<<AD9850_DATA); // Data low
}
// Clock
//AD9850_wait();
AD9850_PORT |= (1<<AD9850_CLK);
AD9850_wait();
AD9850_PORT &= ~(1<<AD9850_CLK);
AD9850_wait();
i--;
data = (data>>1);
} while (i>0);
}
int main (void)
{
// Initialisierungen
AD9850_Init();
frequency = 40000000;
AD9850_SendFrequency((frequency * pow(2, 32)) / DDS_CLOCK);
while(1)
{
}
}
Und was zeigt der Zähler an ? Juhu ! 40 MHz !!!!!
Nur bei NF-Werten weicht der Wert ab......
Ich vermute, dass ich einen Filter nachschalten muss.... obwohl der Sinus sauber aussieht....