Hello,
I am using the AD9833 chip to generate a 100kHz sine wave using the data coming from the SPI bus configured in my S32k358 microcontroller. I have set the SPI bus using the LPSPI RTD driver. I have defined a function that sets the FSYNC pin low, pushes the data and the sets the FSYNC pin back to high. I have attached my LPSPI configuartions
Based on the configuration, i am able to get the SPI wavforms, butstill the control register of the DAC is not getting set.
As per the datasheet and application note AN-1070 following is my code to manipulate the equivalent data into the DAC:
DAC_data_send(0x2100); //RESET ON
data = 1073742;//100000Hz equivalent 16 bit data from SPI2 MOSI
uint16 MSB = (uint16)((data & 0xFFFC000) >> 14); // extracting MSB and setting control bits for FREQREG0
uint16 LSB = (uint16)(data & 0x3FFF); // extracting LSB and setting control bits for FREQREG0
LSB |= 0x4000; // Control bits for LSB for FREQREG0, 0x8000; // Control bits for LSB for FREQ1
MSB |= 0x4000; // Control bits for MSB for FREQREG0, 0x8000; // Control bits for MSB for FREQ1
DAC_data_send(LSB); //Writing 14 bit LSB to Freq Register 0
DAC_data_send(MSB); //Writing 14 bit MSB to Freq Register 0
DAC_data_send(0xC000); // Setting Phase Adjustment in the Phase Register 0
DAC_data_send(0x2000); // RESET OFF*/
The value 1073742 is by this calculation - (100000*2^28)/(25*10^6). I have followed the formula given in the datasheet. I dont know where i am going wrong, can someone point me out