ad9850 square wave problem

hi all
I’m working on AD9850 with Arduino uno and I want to have a variable frequency square wave output. I get the answer But the output frequency is from 0Hz up to 1 Khz. anyone knows How can I get frequency up to 10 Khz?

the program is attached.

thank you

ad9850.txt (1.85 KB)

Will an Arduino long data type hold the result of that calculation?

void loop(){
  while(1) {
    sweep(100000, 400000, 20, 1000); // wenn Frequenzen durchgesweept werden sollen

An endless loop inside and endless loop?