• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Do you have to turn off LVP 16f88

Status
Not open for further replies.

be80be

Well-Known Member
Do you have to turn off LVP to use RB3 as output on 16f88 ? Or do you just need to make sure RB3 is not floating
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.
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.:confused:
 

Pommie

Well-Known Member
Most Helpful Member
If you use LVP then RB3 is used to switch to programming mode. If you want it to run your code then RB3 has to be tied to ground.

If you want to use it as an I/O pin then you must use HVP.

As you have a PicKit2, which is a high voltage programmer, why are you bothering with LVP?

Mike.
 

be80be

Well-Known Member
Like I said last night I turn off the LVP on the 16f88 didn't need it and I wanted the IO RB3
and it lock the chip. I thought I was using HVP but the new pickkit 2 v2.60 set the programmer to LVP ever time I start it up. And it finds a 16f88. So I'm right in thinking If I
want RB 3 leave LVP off and I'm good to go.
 

Pommie

Well-Known Member
Most Helpful Member
You can't "leave LVP off" as the chips come from the factory with LVP enabled (on). You have to clear the LVP bit in the config settings in order to turn LVP off and make RB3 an I/O pin. Just write your code with LVP_OFF in the config settings and RB3 will be an I/O pin like all the others.

Mike.
 

be80be

Well-Known Member
Thanks I know that now after reading the whole datasheet for the 16f88 I did change the
config settings set LVP_OFF. Some one posted here some where not to do that. But I want the I/O on RB3 and that's the only way to get it. Mike do you no of any good howto's on tables. I'm trying to use them for my leds
Code:
      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
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
This is how I do it to read an 8 byte table,

Code:
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-
The above will return the Offset+1'th byte from the table. I.E. if offset contains 2 it will return the third value. Note to use it you have to call GetStep.

Mike.
 

be80be

Well-Known Member
I have tried about the same thing but it didn't show up on portb
Code:
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
 
Last edited:

be80be

Well-Known Member
This is how I tried what you posted
Code:
   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
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
You really need to separate your code into identifiable sections. The way your code is at the moment, the delay routine never gets executed because when the movwf PCL executes it jumps into the table. The table consists of return instructions and so it returns to the line after the call GetStep. Place the code I posted earlier at the end of your code and just call it, don't put bits of code in the middle of it. It will then work correctly.

Mike.
 

be80be

Well-Known Member
What a way to start the day my shop got flooded. Soaked my computer and all the boards I use for testing had covered in water. The only thing not wet is my pickit2. What makes me the maddest Is all my books are wet to. I was just getting them all back after my ex thew them a way.
 

be80be

Well-Known Member
I tried it like This is this not right . I just want to change portB with a table. so I change what leds light
Code:
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
 

be80be

Well-Known Member
I tried this The led don't come on
Code:
 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
 

Sceadwian

Banned
lol
I think everyone that uses micro controllers does this at some point.
Almost all of them start up their I/O lines as inputs. If you see any glow on the LED's it's from the pullups turning on. might be able to see it in a really dark r oom.
 

be80be

Well-Known Member
I tried this still no go It just sets with 1 led lit.
Code:
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
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top