Hello, the code is :
Code:
'// PIC 16F877A
ADCON1=7
CMCON=7
OPTION_REG=%00000111
TRISA=%111111 : TRISE=%111
TRISB=0 : PORTB=0
TRISC=%10001111 : PORTC=0
TRISD=%00000011 : PORTD=0
CCP1CON=0
@ ERRORLEVEL -306
B VAR BYTE
C VARY BYTE
D VAR BYTE
		B=PortB : C[0]=PortC.5
		for q=2 to 7
			D[q]=PortD[q]
		next q
	IF B=0 and C=0 and D=0 then
		toggle BUZ: pause 20
	endif
As you can see I am trying to load ports into the variables. All ports above are outputs.
The problem:
When any of portB is made high in the main program then buzzer is off, as it should be, same is true for portc.5, but PortD is not being read properly. Even if lets say I make PortD.2 to D.7 high, one by one in the code for lets say 2 sec each (2 sec high/ 2 sec low) the buzzer is toggling non-stop. Though it should only toggle during 2 sec Low period.
Can someone help please? Thanks