/*****************************************************************************/ /* */ /* ad5932.c */ /* */ /* Routinen zur Ansteuerung des AD5932 DDS-Chips */ /* */ /* (2008) Universität Stuttgart / IZFM (Dipl.-Ing.(FH) Klaus Skibowski) */ /* */ /* geändert auf ATMega88 und einen AD5932 */ /* */ /* Version: 1 */ /* Datum: 22.02.2010 */ /* Name: Martin Ernst */ /*****************************************************************************/ #ifndef F_CPU #define F_CPU 18432000UL #endif #include "ad5932.h" #include #include #include #include #include #include #include #include "lcd_lib.h" //#include "entprell.h" // Definition der Bits des Controllregister #define D0 0x00 #define D1 0x01 #define D2 0x02 #define D3 0x03 #define D4 0x04 #define D5 0x05 #define D6 0x06 #define D7 0x07 #define D8 0x00 #define D9 0x01 #define D10 0x02 #define D11 0x03 #define D12 0x04 #define D13 0x05 #define D14 0x06 #define D15 0x07 #define FSYNC_HIGH PORTB |= (1<>12) & 0x0FFF)); low = (unsigned int)((freq_word & 0x00000FFF)); ad5932_write(AD5932_FSTART_LOW | low); ad5932_write(AD5932_FSTART_HIGH | high); //_delay_ms(10); CTRL_HIGH; } /* void ad5932_set_delta_f(double wert) { unsigned int high,low; unsigned long freq_word; unsigned char sign; if (wert<0) sign = 1; else sign = 0; freq_word = (unsigned long)((abs(wert)*mclk_faktor)); //fabs(wert) high = (unsigned int)(((freq_word>>11) & 0x07FF)); low = (unsigned int)((freq_word & 0x00000FFF)); ad5932_write(AD5932_DELTA_F_LOW | low); if (sign) { ad5932_write(AD5932_DELTA_F_HIGH | 0x0800 | high); } else { ad5932_write(AD5932_DELTA_F_HIGH | high); } } */ /* void ad5932_set_n_inc(unsigned int wert) { ad5932_write(AD5932_N_INC | (wert & 0x0FFF)); } */ void ad5932_write(unsigned int wert) { FSYNC_LOW; // AD5932 --> SPI aktivieren SPDR = (unsigned char)(wert>>8); // höherwertiges Byte senden while ( !(SPSR & (1< SPI deaktivieren } void ad5932_start(void) { CTRL_LOW; _delay_ms(100); CTRL_HIGH; } /*void ad5932_reset(void) { INT_HIGH; _delay_ms(10); INT_LOW; }*/ int main(void) { DDRD |= (1< Ausgang //DDRB |= (1<