Author Topic: Help with mpasm  (Read 472 times)

0 Members and 1 Guest are viewing this topic.

Offline Dule

  • Contributor
  • Posts: 9
Help with mpasm
« on: October 25, 2017, 07:21:17 pm »
Hi there,

I am trying to teach myself mpasm so I wrote a small program that was supposed to spin stepper motor one revolution in alternate directions.

I am using pololu breakout board for A4988 driver

However, my program just drives stepper non-stop in one direction. For some reason, it appears to be stuck in first loop and I can't figure out why.

I would really appreciate if anybody could point out mistake to me as I have been stuck with this for the past few days without success.


   list      p=10F200            ; list directive to define processor
 #include <>        ; processor specific variable definitions


; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

dc1    res 1
dc2    res 1   

RCCAL CODE   0x0FF       ; processor reset vector
      res 1
; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.
RESET   CODE    0x000
   movwf   OSCCAL            ; update register with factory cal value

   movlw b'11111100'              ; Set GP1 output (pulse) and
        tris GPIO                             ; Set GP0 output (direction)
   movlw b'00000001'              ; Set direction to 1
   movwf GPIO
   movlw .200
   movwf dc2
   bsf GPIO,1                     ;Set GP1 high
   call delay                     ; 1 ms delay
   bcf GPIO,1                     ; Set GP1 Low
   call delay                     ; 1 ms delay
   decfsz dc2,f
   goto loop_1
   movlw b'00000000'               ;Set direction 0   
   movwf GPIO
   movlw .200                      ; 200 x 1.8 degree =360 degree
   movwf dc2                       ; One full rotation of stepper
   bsf GPIO,1                       ;Set GP1 high
   call delay                       ; 1 ms delay
   bcf GPIO,1                       ;Set GP1 low
   call delay                       ; 1 ms delay
   decfsz dc2,f
   goto loop_2
   goto main_loop   
SUBS     CODE   
delay                            ; 1ms delay
   clrf dc1
   decfsz dc1,f
   goto dly_1
   END                       ; directive 'end of program'


Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2122
  • Country: se
  • Country: Broken Britain
Re: Help with mpasm
« Reply #1 on: October 25, 2017, 08:24:35 pm »
Well there's no return at the end of "delay".
CML+  That took much longer than I thought it would.

Offline Dule

  • Contributor
  • Posts: 9
Re: Help with mpasm
« Reply #2 on: October 25, 2017, 09:54:06 pm »
Thank you  :) !!! problem solved


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo