Hello Darrel,

I have some more weirdness going on. I got my code to work, but not the way I want it to.

When I read PortB using LatB, I can't seem to detect a set bit on B1. When I write directly to the
variable in my case statement I can step through the values and the outputs are correct. I can't
what is wrong with what I have. Code below.

ASM
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF & _LVP_OFF & _STVREN_OFF

ENDASM

DEFINE OSC 8



;************************************************* ******************************
;************************************************* ******************************
; System hardware configuration
;************************************************* ******************************
;************************************************* ******************************

OSCCON = %01110000 ' 8MHz internal
ANSELA = %00000000 ' all digital. A/D disabled
ANSELB = %00000000
TRISB = %00111111 ' set port directions 0 = output, 1 = input
TRISA = %00000000

Servo1 var byte
Servo2 var byte


srv2 VAR LATA.1
srv1 VAR LATA.0
PrtB VAR LATB

Program_init:
PortA = 0
POrtB = 0


Main_Loop:



Servo1 = PrtB and %00000111
gosub Servo_update1

Servo2 = PrtB and %00111000
gosub servo_update2

pause 10

goto main_loop


Servo_update1:

select case Servo1
case 0
srv1 = 1 : pauseus 1000 : srv1 = 0

CASE 1
srv1 = 1 : pauseus 1143 : srv1 = 0

case 2
srv1 = 1 : pauseus 1286 : srv1 = 0

case 3
srv1 = 1 : pauseus 1429 : srv1 = 0

CASE 4
srv1 = 1 : pauseus 1572 : srv1 = 0

case 5
srv1 = 1 : pauseus 1715 : srv1 = 0

Case 6
srv1 = 1 : pauseus 1858 : srv1 = 0

Case 7
srv1 = 1 : pauseus 2000 : srv1 = 0

END SELECT

return


Servo_update2:

select case Servo2
case 0
srv2 = 1 : pauseus 1000 : srv2 = 0

CASE 8
srv2 = 1 : pauseus 1143 : srv2 = 0

case 16
srv2 = 1 : pauseus 1286 : srv2 = 0

case 24
srv2 = 1 : pauseus 1429 : srv2 = 0

CASE 32
srv2 = 1 : pauseus 1572 : srv2 = 0

case 40
srv2 = 1 : pauseus 1715 : srv2 = 0

Case 48
srv2 = 1 : pauseus 1858 : srv2 = 0

Case 56
srv2 = 1 : pauseus 2000 : srv2 = 0

END SELECT

return