That what it said here but there a part that said to to use a resistor on it to make sure it not floating if you use it as an output.If Low-Voltage Programming mode is not used, the LVP
bit can be programmed to a ‘0’ and RB3/PGM becomes
a digital I/O pin. However, the LVP bit may only be
programmed when Programming mode is entered with
VIHH on MCLR. The LVP bit can only be changed when
using high voltage on MCLR.
It should be noted that once the LVP bit is programmed
to ‘0’, only the High-Voltage Programming mode is
available and only this mode can be used to program
the device.
movlw TableStart ; want it to output to portB
[COLOR="red"]; I don't get what i need here to make it happen[/COLOR]
TableStart:
retlw b'00000001' ; 0
retlw b'00000010' ; 1
retlw b'00000100' ; 2
retlw b'00001000' ; 3
retlw b'00010000' ; 4
end
GetStep movlw high StepTab
movwf PCLATH
movfw Offset
addlw low StepTab
btfsc STATUS,C
incf PCLATH,F
movwf PCL
StepTab
retlw b'1000' ;A+ B0
retlw b'1010' ;A+ B+
retlw b'0010' ;A0 B+
retlw b'0110' ;A- B+
retlw b'0100' ;A- B0
retlw b'0101' ;A- B-
retlw b'0001' ;A0 B-
retlw b'1001' ;A+ B-
BinaryToGrayCode:
movlw high TableStart ; get high order part of the beginning of the table
movwf PCLATH
movlw low TableStart ; load starting address of table
addwf temp,w ; add offset
btfsc STATUS,C ; did it overflow?
incf PCLATH,f ; yes: increment PCLATH
movwf PCL ; modify PCL
TableStart:
retlw b'0000' ; 0
retlw b'0001' ; 1
retlw b'0011' ; 2
retlw b'0010' ; 3
retlw b'0110' ; 4
retlw b'0111' ; 5
retlw b'0101' ; 6
retlw b'0100' ; 7
retlw b'1100' ; 8
retlw b'1101' ; 9
retlw b'1111' ; 10
retlw b'1110' ; 11
retlw b'1010' ; 12
retlw b'1011' ; 13
LIST p=16F88 ;tell assembler what chip we are using
include "P16F88.inc" ;include the defaults for the chip
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
cblock 0x20 ;start of general purpose registers
d1
d2
d3
Offset
endc
ORG 0x0000 ; processor reset vector
GOTO START ; go to beginning of program
START:
banksel OSCCON
movlw b'01110010'
movwf OSCCON
RESET clrf STATUS ; |B0
clrf PORTA ; clear Port A data latches |B0
clrf PORTB ; clear Port B data latches |B0
movlw h'07' ; |B0
movwf CMCON ; turn comparator off |B0
bsf STATUS,RP0 ; select bank 1 |B1
bcf STATUS,RP0 ; select bank 0 |B0
goto main
main:
call GetStep
movwf PORTB
call delay
goto main
GetStep
movlw high StepTab
movwf PCLATH
movfw Offset
addlw low StepTab
btfsc STATUS,C
incf PCLATH,F
movwf PCL
delay ;499994 cycles
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
retlw 0x00
StepTab
retlw b'1000' ;A+ B0
retlw b'1010' ;A+ B+
retlw b'0010' ;A0 B+
retlw b'0110' ;A- B+
retlw b'0100' ;A- B0
retlw b'0101' ;A- B-
retlw b'0001' ;A0 B-
retlw b'1001' ;A+ B-
end
start:
call delay
call GetStep
goto start
delay ;499994 cycles
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
retlw 0x00
GetStep
movlw high StepTab
movwf PCLATH
movfw Offset
addlw low StepTab
btfsc STATUS,C
incf PCLATH,F
movwf PCL
StepTab
retlw b'1000' ;A+ B0
retlw b'1010' ;A+ B+
retlw b'0010' ;A0 B+
retlw b'0110' ;A- B+
retlw b'0100' ;A- B0
retlw b'0101' ;A- B-
retlw b'0001' ;A0 B-
retlw b'1001' ;A+ B-
end
LIST p=16F88 ;tell assembler what chip we are using
include "P16F88.inc" ;include the defaults for the chip
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
cblock 0x20 ;start of general purpose registers
d1
d2
d3
count
endc
ORG 0x0000 ; processor reset vector
GOTO init ; go to beginning of program
init:
banksel OSCCON
movlw b'01110010'
movwf OSCCON
RESET clrf STATUS ; |B0
clrf PORTA ; clear Port A data latches |B0
clrf PORTB ; clear Port B data latches |B0
movlw h'07' ; |B0
movwf CMCON ; turn comparator off |B0
goto Start
Start clrf count ;set counter register to zero
Read movf count, w ;put counter value in W
call Table
movwf PORTB
call delay
incf count, w
xorlw d'14' ;check for last (14th) entry
btfsc STATUS, Z
goto Start ;if start from beginning
incf count, f ;else do next
goto Read
Table ADDWF PCL, f ;data table for bit pattern
retlw b'10000000'
retlw b'01000000'
retlw b'00100000'
retlw b'00010000'
retlw b'00001000'
retlw b'00000100'
retlw b'00000010'
retlw b'00000001'
retlw b'00000010'
retlw b'00000100'
retlw b'00001000'
retlw b'00010000'
retlw b'00100000'
retlw b'01000000'
delay ;249998 cycles
movlw 0x4F
movwf d1
movlw 0xC4
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
retlw 0x00
end
init:
banksel OSCCON
movlw b'01110010'
movwf OSCCON
RESET clrf STATUS ;
clrf PORTA ; clear Port A data latches
clrf PORTB ; clear Port B data latches
movlw h'07' ;
movwf CMCON ; turn comparator off
banksel TRISB
movlw b'00000000'
movwf TRISB
banksel PORTB
clrf PORTB
goto Start
Start clrf count ;set counter register to zero
Read
movf count, w ;put counter value in W
call Table
movwf PORTB
call delay
incf count, w
xorlw d'14' ;check for last (14th) entry
btfsc STATUS, Z
goto Start ;if start from beginning
incf count, f ;else do next
goto Read
Table ADDWF PCL, f ;data table for bit pattern
retlw b'10000000'
retlw b'01000000'
retlw b'00100000'
retlw b'00010000'
retlw b'00001000'
retlw b'00000100'
retlw b'00000010'
retlw b'00000001'
retlw b'00000010'
retlw b'00000100'
retlw b'00001000'
retlw b'00010000'
retlw b'00100000'
retlw b'01000000'
delay ;249998 cycles
movlw 0x4F
movwf d1
movlw 0xC4
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
retlw 0x00
end
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?