I wanna control dual ad9837 by Atmel at32uc microprocessor. Write a random frequency number to both ad9837, for example, in a range of 20 - 30 KHz, but do not sweep the frequency. One of ad9837 generates the square wave with 0 degree phase shift, but, other will generate the same frequency square wave with 90 degree phase shift.
But the problem is that the output of both square waves cannot keep a stable 90 degree phase shift. Sometime, it is 0 degree, and sometime it is less than 90, 80 degree like that, or, bigger than 90.
The fake code like that:
- Init_ad9837, and reset ad9837 and send 0x2100 to both ad9837, ad9837_0 and ad9837_1
- Write 0 degree phase shift to PHASE0 and PHASE1 of ad9837_0
- Write 90 degree phase shift to PHASE0 and PHASE1 of ad9837_1
- Enter a loop:
- Get a random frequency number
// first time, write frequency value to FREQ0 of both ad9837, but load FREQ1 as output
- Write LSB of the random number to FREQ0 of both ad9837
- Write MSB of the random number to FREQ0 of both ad9837
- Write 0x2868 to load the FREQ1 and PHASE1 of both ad9837 to produce square waves
// Sec. time, write frequency value to FREQ1 of both ad9837, but load FREQ0 as output
- Write LSB of the random number to FREQ1 of both ad9837
- Write MSB of the random number to FREQ1 of both ad9837
- Write 0x2068 to load the FREQ0 and PHASE0 of both ad9837 to produce square waves
//get a new random number and repeat the first time….
The loop always fetches the previous random frequency number as current output frequency. But the both output cannot keep a stable 90 degree phase shift.
Even, I try to use one FREQ and PHASE register of both ad9837 to generate the signals, don’t use this alternate way to write them, but it still has same problem. and I also try rewrite phase regisiter values in the loop, same prblem.
IF I put a reset 0x2100 in the loop before getting the random number, the output signals can keep a stable phase shfit, but undesired "blinking" waves around the output, (i think it is caused by the reset command,) and these produced signals are not allowed for further applications.