/* * ad9833 basic.cpp * * Created: 17/04/2018 18:18:25 * Author : ed */ #define F_CPU 16000000L #include #include #include #include #include #define USART_BAUDRATE 31250 #define UBRR_VALUE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1) #define IS_ODD(x) ((x) & 1) #define IS_EVEN(x) (!(IS_ODD(x))) /*name AD9833 command register bits */ #define AD_B28 0x2000 #define AD_HLB 0x1000 #define AD_FSELECT 0x0800 #define AD_PSELECT 0x0400 #define AD_RESET 0x0100 #define AD_SLEEP1 0x0080 #define AD_SLEEP12 0x0040 #define AD_OPBITEN 0x0020 #define AD_DIV2 0x0008 /* name AD9833 register addresses */ #define AD_FREQ0 0x4000 #define AD_FREQ1 0x8000 #define AD_PHASE0 0xC000 #define AD_PHASE1 0xE000 #define AD_SQUARE (0x2000 | 0x28) #define AD_SINE 0x2000 #define AD_TRI 0x2002 /* chip select for AD9833 */ #define cs_AD9833_low PORTB &= ~(1<>8) & 0xFF); // send high Byte while ( !(SPSR & (1<>16)));//HIGH word for DDS low = uint16_t (AD_FREQ0 | (0x3FFF&(uint16_t)(frequency_word>>2 )));//LOW word for DDS /* wave shapes are: AD_SINE, AD_SQUARE or AD_TRI remember: AD_SQUARE puts out a square of 0 - 5volt, while AD_TRI and AD_SINE puts out 0 - 0.65 volt */ ad9833_send(AD_TRI);// set waveform shape ad9833_send(low);//low word ad9833_send(high);//high word } int main (void) { init(); ad9833_set_frequency(1500.1); while (1) { } }