Add Servo Motors

0560;    A0_servo; 3022; MOVLW 0x22; W=22h or 34d
0561;            ; 067B; XORWF 0x7B, W; CMD
0562;            ; 1D03; BTFSS 0x03, 2; STATUS_Z
0563;            ; 0008; RETURN;
0564;            ; 0021; MOVLB 01;
0565;            ; 100C; BCF 0x0C, 0; TRISA_TRISA0
0566;            ; 0022; MOVLB 02;
0567;            ; 100C; BCF 0x0C, 0; LATA_LATA0
0568;        20ms; 3014; MOVLW 0x14; W=14h or 20d
0569;            ; 0022; MOVLB 0x02;
056A;            ; 00EC; MOVWF 0x6C; 
056B;    pause_ms; 202A; CALL 0x02A; 
056C;            ; 140C; BSF 0x0C, 0; LATA_LATA0
056D;         1ms; 3001; MOVLW 0x01; W=01h or 1d
056E;            ; 00EC; MOVWF 0x6C; 
056F;    pause_ms; 202A; CALL 0x02A; 
0570;            ; 1C7C; BTFSS 0x7C, 0; ARG_bit0
0571;            ; 0008; RETURN;
0572;         5ms; 3005; MOVLW 0x05; W=05h or 5d
0573;            ; 00EC; MOVWF 0x6C; 
0574;    pause_ms; 202A; CALL 0x02A; 
0575;            ; 0008; RETURN;

Button 22 in the CMDR™ app is selected to control a servo attached to port A0. Button 22 sends the command “0x22” to the CMDO™ along with an argument that could be either ‘0’ or ‘1’. First the code above checks for the command ‘0x22’ before proceeding and then sets port A0 as an output with a low enabled. Then the program loads a variable into the W-register for a 20ms pause. The pause_ms routine stops program execution until a loop of no-ops is executed to achieve a 20ms pause. After the 20ms wait pause_ms is called again either 1ms for an ‘ARG’= 0 of 5ms if ‘ARG’= 1;