For 38kHz on RB0 & RB1, and 19kHz on RB6, you'll need to modify the delay
routines. This should work for ~38kHz & 19kHz. It's off by a few 100Hz, but
a lot closer than the other version.
Code:
' For 4MHz use XT_OSC
@ DEVICE PIC16F84A, XT_OSC,WDT_OFF,PROTECT_OFF,PWRT_ON
' For 4MHz use
DEFINE OSC 4
ltime VAR BYTE
TRISB = 0
GOTO Main
PAUSE9:
ASM
GOTO $+1 ; 2uS
GOTO $+1 ; 2uS
GOTO $+1 ; 2uS
NOP ; 1uS
RETURN ; 2uS
ENDASM
PAUSE7:
ASM
GOTO $+1 ; 2uS
GOTO $+1 ; 2uS
NOP ; 1uS
RETURN ; 2uS
ENDASM
Main:
FOR ltime = 0 TO 49 ' 0 TO 49 = 50 loops total
PORTB.7 = 1
PAUSE 50
PORTB.7 = 0
PAUSE 50
NEXT ltime
WHILE 1=1
PORTB = 1
CALL PAUSE9 ' CALL = 2uS
PORTB = 2
CALL PAUSE9
PORTB = $41
CALL PAUSE9
PORTB = $42
CALL PAUSE7 ' Compensates for GOTO beginning of WHILE loop
WEND
END
Bookmarks