Program for LEDs

0540;      C7_led; 1C7D; BTFSS 0x7D, 0; FLAG_NewCmd
0541;            ; 0008; RETURN;
0542;            ; 3021; MOVLW 0x21; W=21h or 33d
0543;            ; 067B; XORWF 0x7B, W; CMD
0544;            ; 1D03; BTFSS 0x03, 2; STATUS_Z
0545;            ; 0008; RETURN;
0546;            ; 107D; BCF 0x7D, 0; FLAG_NewCmd
0547;            ; 0021; MOVLB 0x01;
0548;            ; 138E; BCF 0x0E, 7; TRISC_TRISC7
0549;            ; 0022; MOVLB 02;
054A;            ; 138E; BCF 0x0E, 7; LATC_LATC7
054B;            ; 1C7C; BTFSS 0x7C, 0; ARG_bit0
054C;            ; 0008; RETURN;
054D;            ; 0022; MOVLB 02;
054E;            ; 178E; BSF 0x0E, 7; LATC_LATC7
054F;            ; 0008; RETURN;

Button 21 in the CMDR™ app is selected to control an led attached to port C7. Button 21 sends the command “0x21” to the CMDO™ along with an argument that could be either ‘0’ or ‘1’. The code above first checks the NewCmd flag to see if there is a new command to process otherwise it immediately returns. If the command ‘0x21’ is received it clears the NewCmd flag, sets C7 as an output, and then turns port C7 off. The code then checks the ‘ARG’ variable to see if it’s a ‘1’. If it is it turns port C7 back on.