OOPS, you're right.
Somehow, in the process of posting it, I lost two 0's in the third DIV32.
This works better.Code:<font color="#000000"><b>Freq1 </b><font color="#008000"><b>VAR WORD </b></font><b>Freq2 </b><font color="#008000"><b>VAR WORD </b></font><b>N </b><font color="#008000"><b>VAR WORD </b></font><b>A </b><font color="#008000"><b>VAR WORD </b></font><b>Remainder </b><font color="#008000"><b>VAR WORD </b></font><font color="#0000FF"><b><i>; --- Frequency must be split into 2 variables --- </i></b></font><b>Freq1 </b>= <b>4336 </b><font color="#0000FF"><b><i>; 433687.5 </i></b></font><b>Freq2 </b>= <b>875 </b><font color="#008000"><b>GOSUB </b></font><b>PLL_Calc </b><font color="#008000"><b>STOP </b></font><b>PLL_Calc</b>: <b>N </b>= (<b>5018 </b>- <b>Freq1</b>) <font color="#008000"><b>IF </b></font><b>Freq2 </b>> <b>0 </b><font color="#008000"><b>THEN </b></font><b>A </b>= <b>1000 </b>- <b>Freq2 N </b>= <b>N </b>- <b>1 </b><font color="#008000"><b>ELSE </b></font><b>A </b>= <b>0 </b><font color="#008000"><b>ENDIF </b></font><b>N </b>= <b>N </b>* <b>8 A </b>= <b>A </b>* <b>8 N </b>= <b>N </b>+ (<b>A</b>/<b>1000</b>) <b>A </b>= <b>A </b>- (<b>A</b>/<b>1000</b>*<b>1000</b>) <b>N </b>= <b>N</b>*<b>10 N </b>= <font color="#008000"><b>DIV32 </b></font><b>64 Remainder </b>= <b>R2 Remainder </b>= <b>Remainder </b>* <b>10000 Remainder </b>= <font color="#008000"><b>DIV32 </b></font><b>64 A </b>= <b>A </b>* <b>10000 A </b>= <font color="#008000"><b>DIV32 </b></font><b>6400 <font color="#0000FF">; <-- Changed, was 64</font> A </b>= <b>A </b>+ <b>Remainder A </b>= <b>A </b>* <b>64 A </b>= <font color="#008000"><b>DIV32 </b></font><b>10000 Remainder </b>= <b>R2 </b><font color="#008000"><b>IF </b></font><b>Remainder </b>>= <b>5000 </b><font color="#008000"><b>THEN </b></font><b>A </b>= <b>A </b>+ <b>1 </b><font color="#008000"><b>RETURN</b></font>




Bookmarks