Mathematics and remainder for PLL MC145158


Results 1 to 16 of 16

Threaded View

  1. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Well, nevermind, I got it figured out anyway.

    Give this a try.
    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>&gt; <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>64                   
        
        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>&gt;= <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>
    Last edited by Darrel Taylor; - 18th August 2005 at 07:45.
    DT

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts