The Art of Programming Microchips

Status
Not open for further replies.
Hi


Please could you have a quick look at this for me .. .


_main:

;Stepper Driving Bipolar.c,1 :: void main()
;Stepper Driving Bipolar.c,3 :: CMCON = 0x07; // To turn off comparators
MOVLW 7
MOVWF CMCON+0
;Stepper Driving Bipolar.c,4 :: ADCON1 = 0x06; // To turn off analog to digital converters
MOVLW 6
MOVWF ADCON1+0
;Stepper Driving Bipolar.c,6 :: TRISB = 0; // PORT B as output port
CLRF TRISB+0
;Stepper Driving Bipolar.c,7 :: PORTB = 0x0F;
MOVLW 15
MOVWF PORTB+0
;Stepper Driving Bipolar.c,9 :: do
L_main0:
;Stepper Driving Bipolar.c,11 :: PORTB = 0b00000001;
MOVLW 1
MOVWF PORTB+0
;Stepper Driving Bipolar.c,12 :: Delay_ms(100);
MOVLW 6
MOVWF R11+0
MOVLW 19
MOVWF R12+0
MOVLW 173
MOVWF R13+0
L_main3:
DECFSZ R13+0, 1
GOTO L_main3
DECFSZ R12+0, 1
GOTO L_main3
DECFSZ R11+0, 1
GOTO L_main3
NOP
NOP
;Stepper Driving Bipolar.c,13 :: PORTB = 0b00000100;
MOVLW 4
MOVWF PORTB+0
;Stepper Driving Bipolar.c,14 :: Delay_ms(100);
MOVLW 6
MOVWF R11+0
MOVLW 19
MOVWF R12+0
MOVLW 173
MOVWF R13+0
L_main4:
DECFSZ R13+0, 1
GOTO L_main4
DECFSZ R12+0, 1
GOTO L_main4
DECFSZ R11+0, 1
GOTO L_main4
NOP
NOP
;Stepper Driving Bipolar.c,15 :: PORTB = 0b00000010;
MOVLW 2
MOVWF PORTB+0
;Stepper Driving Bipolar.c,16 :: Delay_ms(100);
MOVLW 6
MOVWF R11+0
MOVLW 19
MOVWF R12+0
MOVLW 173
MOVWF R13+0
L_main5:
DECFSZ R13+0, 1
GOTO L_main5
DECFSZ R12+0, 1
GOTO L_main5
DECFSZ R11+0, 1
GOTO L_main5
NOP
NOP
;Stepper Driving Bipolar.c,17 :: PORTB = 0b00001000;
MOVLW 8
MOVWF PORTB+0
;Stepper Driving Bipolar.c,18 :: Delay_ms(100);
MOVLW 6
MOVWF R11+0
MOVLW 19
MOVWF R12+0
MOVLW 173
MOVWF R13+0
L_main6:
DECFSZ R13+0, 1
GOTO L_main6
DECFSZ R12+0, 1
GOTO L_main6
DECFSZ R11+0, 1
GOTO L_main6
NOP
NOP
;Stepper Driving Bipolar.c,19 :: }while(1);
GOTO L_main0
;Stepper Driving Bipolar.c,20 :: }
GOTO $+0
; end of _main


This is the source code for the stepper motor driver I was trying to build on Sunday. Using my new found MPlab skills, I got it to work this morning but it was very, very slow. I decided this was because there was a delay written in of 500ms after each pulse, so I changed it to 100ms, as above. But now when I ask MPASM to compile it, it comes up with a whole string of errors and eventually 100% failed to compile - what have I done wrong ?

S
 
You posted the .ASM file created by the compiler

Code:
#include<pic.h>

void main()
   {
   CMCON = 0x07;    // To turn off comparators
   ADCON1 = 0x06;    // To turn off analog to digital converters
   TRISB = 0;    // PORT B as output port
   PORTB = 0x0F;
   do
     {
     PORTB = 0b00000001;
     Delay_ms(100);
     PORTB = 0b00000100;
     Delay_ms(100);
     PORTB = 0b00000010;
     Delay_ms(100);
     PORTB = 0b00001000;
     Delay_ms(100);
     }while(1);
   }

This is your C file... BUT!!!! the first brace '{' after void main() was missing!!
You should just work on the C file...
 
AH IC .. .. and .. I understand .. Thanks Ian

That file I pasted is labelled Stepper Motor.c .. because I've saved as a C file haven't I ? Prairie 'at !

Thanks

S
 
Easier to read if you use code tags, and I use a a more traditional way of formatting code.
Max.


Code:
_main:

;Stepper Driving Bipolar.c,1 :: void main()
;Stepper Driving Bipolar.c,3 :: CMCON = 0x07; // To turn off comparators
        movlw 7
        movwf CMCON+0
;Stepper Driving Bipolar.c,4 :: ADCON1 = 0x06; // To turn off analog to digital converters
         movlw 6
        movwf ADCON1+0
;Stepper Driving Bipolar.c,6 :: TRISB = 0; // PORT B as output port
        clrf TRISB+0
;Stepper Driving Bipolar.c,7 :: PORTB = 0x0F;
        movlw 15
        movwf PORTB+0
;Stepper Driving Bipolar.c,9 :: do
L_main0:
;Stepper Driving Bipolar.c,11 :: PORTB = 0b00000001;
        movlw 1
        movwf PORTB+0
;Stepper Driving Bipolar.c,12 :: Delay_ms(100);
        movlw 6
        movwf R11+0
        movlw 19
        movwf R12+0
        movlw 173
        movwf R13+0
L_main3:
        decfsz R13+0, 1
        goto L_main3
        decfsz R12+0, 1
        goto L_main3
        decfsz R11+0, 1
        goto L_main3
        NOP
        NOP
;Stepper Driving Bipolar.c,13 :: PORTB = 0b00000100;
        movlw 4
        movwf PORTB+0
;Stepper Driving Bipolar.c,14 :: Delay_ms(100);
        movlw 6
        movwf R11+0
        movlw 19
        movwf R12+0
        movlw 173
        movwf R13+0
L_main4:
        decfsz R13+0, 1
        goto L_main4
        decfsz R12+0, 1
        goto L_main4
        decfsz R11+0, 1
        goto L_main4
        nop
        nop
;Stepper Driving Bipolar.c,15 :: PORTB = 0b00000010;
        movlw 2
        movwf PORTB+0
;Stepper Driving Bipolar.c,16 :: Delay_ms(100);
        movlw 6
        movwf R11+0
        movlw 19
        movwf R12+0
        movlw 173
        movwf R13+0
L_main5:
        decfsz R13+0, 1
        goto L_main5
        decfsz R12+0, 1
        goto L_main5
        decfsz R11+0, 1
        goto L_main5
        nop
        nop
        ;Stepper Driving Bipolar.c,17 :: PORTB = 0b00001000;
        movlw 8
        movwf PORTB+0
        ;Stepper Driving Bipolar.c,18 :: Delay_ms(100);
        movlw 6
        movwf R11+0
        movlw 19
        movwf R12+0
        movlw 173
        movwf R13+0
L_main6:
        decfsz R13+0, 1
        goto L_main6
        decfsz R12+0, 1
        goto L_main6
        decfsz R11+0, 1
        goto L_main6
        nop
        nop
;Stepper Driving Bipolar.c,19 :: }while(1);
        goto L_main0
;Stepper Driving Bipolar.c,20 :: }
        goto $+0
; end of _main
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…