bogusmeister
Junior Member level 2
Hi guys. i am currently working on a project right now and im having a problem regarding the bit transfer from my pic16f877a to my servo controller. ive done differents set of program codes using assembly but im not able to get any acknowledgement (ACK pin) from the servo controller.. this is the manual that im referring to with sequence and steps (http://www.e-gizmo.com/KIT/images/servokit/ServoController.pdf)..
pls check my codes if it has a problem.. i dont really understand much on how the timing should go and the serial bit transfer. thanks in advance! and happy new year!!!
pls check my codes if it has a problem.. i dont really understand much on how the timing should go and the serial bit transfer. thanks in advance! and happy new year!!!
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 #INCLUDE "P16F877A.INC" __CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF ERRORLEVEL -302 COUNTER EQU 0x0c COUNTERA EQU 0x0d ORG 0x00 GOTO START ORG 0x04 GOTO START START BSF STATUS,RP0 MOVLW 0x02 MOVWF TRISB MOVLW 0x07 MOVWF OPTION_REG BCF STATUS,RP0 CLRF PORTB MAIN BSF PORTB,5 ;SWITCH EN1 TO HIGH CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 ;SET SERVO 1 & 7 ON CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 ;SETS POSITION OF SERVO1 TO 17DEGREES CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE1 CALL ENABLE0 CALL ENABLE0 CALL ENABLE1 CALL ENABLE1 CALL ENABLE1 CALL ENABLE0 ;SETS POSITION OF SERVO7 TO -18DEGREES BSF GOTO MAIN ENABLE1 BSF PORTB,3 ;SWITCH CLK TO HIGH CALL DELAY BCF PORTB,5 ;SWITCH EN1 TO LOW CALL DELAY BSF PORTB,4 ;SEND 1 TO DATA CALL DELAY CLOCK1 BCF PORTB,3 ;SWITCH CLOCK TO LOW CALL DELAY BTFSC PORTB,1 GOTO CLOCK1 RETURN ENABLE0 BSF PORTB,5 ;SWITCH EN1 TO HIGH CALL DELAY BCF PORTB,5 ;SWITCH EN1 TO LOW CALL DELAY BCF PORTB,4 ;SEND 0 TO DATA CALL DELAY CLOCK0 BCF PORTB,3 ;SWITCH CLOCK TO LOW CALL DELAY BTFSC PORTB,1 GOTO CLOCK0 RETURN DELAY MOVLW D'1' MOVWF COUNTER LOOP CALL DELAYA DECFSZ COUNTER,1 GOTO LOOP RETLW 0x00 DELAYA MOVLW D'20' MOVWF COUNTERA LOOPA CALL DELAYB DECFSZ COUNTERA,1 GOTO LOOPA RETLW 0x00 DELAYB CLRF TMR0 BCF INTCON, T0IF LOOPB BTFSS INTCON, T0IF GOTO LOOPB RETLW 0x00 END
Last edited by a moderator: