Cordic trig assembly code for PIC18f


Results 1 to 40 of 55

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Oh! It wasn't as hard as I thought it would be.

    And yup, it's trying to pull the parameters off the stack, and would be overwriting the variables with random values from RAM.
    I assume you've set those variables before calling the routine.

    Commenting these should help...
    Code:
      ; Set up the stack
    ;  movff FSR2L, POSTINC1
    ;  movff FSR1L, FSR2L
    
    
      ; Initialize _ang to passed parameter
    ;  movlw 0xfd
    ;  movff PLUSW2, _ang
    ;  movlw 0xfe
    ;  movff PLUSW2, _ang+1<hr>; Calculates the magnitude and direction of the given ordered pair
    atan2_sqrt:
    
      ; Set up the stack
    ;  movff FSR2L, POSTINC1
    ;  movff FSR1L, FSR2L
    
      ; Initialize _x to passed parameter
    ;  movlw 0xfb
    ;  movff PLUSW2, _x
    ;  movlw 0xfc
    ;  movff PLUSW2, _x+1
    ;  movff POSTINC2, _x
    ;  movff POSTDEC2, _x+1
    
      ; Initialize _y to passed parameter
    ;  movlw 0xfd
    ;  movff PLUSW2, _y
    ;  movlw 0xfe
    ;  movff PLUSW2, _y+1
    ;  movlw 0x03
    ;  movff PLUSW2, _y+1
    ;  movlw 0x02
    ;  movff PLUSW2, _y
    ADDED: OOPs, missed a couple ...
    Code:
      ; Restore the stack to its previous state
    ;  movf POSTDEC1
    ;  movff INDF1, FSR2L
    and there's another banksel atans in the as_loop_start: part.
    Last edited by Darrel Taylor; - 9th February 2009 at 09:48. Reason: Missed some
    DT

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. 4 Chanel Dmx512 ready assembly code to PBP ?
    By syscoder in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st March 2007, 23:55
  5. Your Suggestions: Assembly code material?
    By dw_picbasic in forum General
    Replies: 1
    Last Post: - 2nd February 2007, 17:33

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