Hi Rob,
Yes, I remember the problem with your up/down counter not working properly....
You're still having that Counter variable declared as a WORD but treating it as a 4 byte array in your UP/DOWN subrouitines. That's a crash waiting to happen since the up/down routines writing to the array will write to memory "outside" of the declared variable corrupting what ever is there. I thought we covered that...
When setting the frequency you need to shift 40 bits (32bits tuning value + 8bits control) into the AD9850 and then pulse the Update Frequency pin. Looking at your code I see two main issues (appart from the Counter variable discussed above):
A) In your DDS subroutine that shifts out the tuning value you're only shifting out 8 bits. Even if Counter is declared as a WORD (which it shouldn't be anyway) it will only shift 8 bits when written like that.
B) You're not pulsing the Update Frequency pin, you're toggling it. The AD9850 updates the frequency on the rising edge of that signal so by toggling it like you're doing every second update would fail.
/Henrik.
Bookmarks