AD9833 irrelevant phase change

I am trying to change phase of my signal on ad9833. I can set the frequency to 1KHz sine wave and then display it on scope with another 1KHz square wave from my scope. Then when I try to change phase of my sine wave using the code below, phase changes unexpectedly(trigger is set to 1KHz square wave so I can see the phase drift on sine wave when I change it). I am incrementing phase register by 1 or decrementing it by 1 in somewhere else of my code(Phase register max value is 4095). In which I am expecting steady change on my sine wave but the change is huge sometimes small it does not change according to my code.

Bottom line I am expecting a steady change in phase when I increase/decrease it with a rotary encoder in comparison to another 1KHz square wave which the scope is triggered to.

I send Sıgnal[10] from spi whenever frequency or phase changes as whole.

Can not do this without reference of another 1KHz signal because if I were to use single wave I could not see the phase change due to signal being triggered to its own edges which results in same signal being shown on scope.

Is it possible to change phase in reference to another signal the way I am doing it?

Fixed topic
[edited by: Yorem at 1:00 AM (GMT -5) on 29 Nov 2020]
  • You should pay consideration to the following wording on the datasheet: "Consideration must be given to the relationship of the selected output frequency and the reference clock frequency to avoid unwanted output anomalies".

    If I recall, when you want to switch (step) frequencies you should do so using the two FREQ# registers. That is to ensure phase coherency between the change. I would imagine the same applies to phase (i.e. use the two PHASE# registers). 

    The following guidance is provided on the AD9834 datasheet. I would presume the same applies to the phase registers and to the AD9833:

    "Note however that continuous writes to the same frequency register are not recommended. This results in intermediate updates during the writes. If a frequency sweep, or something similar, is required, it is recommended that users alternate between the two frequency registers