I am trying to generate sine wave using programmable waveform generator AD9833 with ATmega32-A micro controller.(MCLK =8MHz clock frequency). I am using USART communication and so if i change frequency or phase in hyper terminal then the waveform frequency and phase has to change. I wrote small code for this as shown below.
but from the above code I am generating sine wave. If i enter frequency then waveform frequency also changing exactly but i tried to change phase then here is the problem. If i enter phase as 90 then it is changing 10 degree it is not changing 90. I don't know why it is generating like that and what mistake I did? am i missing any bits ? problem with phase only.
Thanks in advance.
If i want enter float value of phase for example 2.5 degree, what i have to change. either "unsigned int phase" into "float phase" in the function. if i try like that the "<<" is not compatible with float.what i have to do if i want to enter phase as 35.8 degree. please suggest me.
Thanks in advance.
From the datasheet page 15:
This signal is phase shifted by 2π/4096 × PHASEREG
If you want to use degrees, modify phase as follows before sending it (uint32_t will probably require the including of the stdint.h file):
phase = (uint32_t)phase * 4096 / 360;
If you aren't particularly concerned about precision you can do the following which would use 16-bit divide instead of 32-bit divide:
phase = phase * (4096 / 360);