• 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.

Tell me why this don't bink a led on a 16f88 it works on all the rest.

Status
Not open for further replies.

be80be

Well-Known Member
:confused:I can't see why this will not work I can't get a 16f88 to Bink a led on portB it will portA
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_ON & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
     __CONFIG    _CONFIG2, _IESO_OFF & _FCMEN_OFF
	cblock 	0x20 			;start of general purpose registers
	d1
	d2
	d3
	endc
	W_TEMP         EQU        0x7D  ; w register for context saving (ACCESS)
	STATUS_TEMP    EQU        0x7E  ; status used for context saving (ACCESS)
	PCLATH_TEMP    EQU        0x7F  ; variable used for context saving
    ORG     0x0000            ; processor reset vector
    GOTO    START             ; go to beginning of program
	
START:
	banksel	OSCCON
	movlw b'00111111'
	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
    clrf    TRISA           ; port A all outputs              |B1
    clrf    TRISB           ; port B all outputs              |B1
    bcf     STATUS,RP0      ; select bank 0                   |B0

	goto	main

main: 

	goto blinkleds
blinkleds:
	banksel	PORTB
    bsf 	PORTB,2
	call 	delay
	bcf		PORTB,2
	call 	delay	
	goto	blinkleds
delay		;999997 cycles
	movlw	0x08
	movwf	d1
	movlw	0x2F
	movwf	d2
	movlw	0x03
	movwf	d3
Delay_0
	decfsz	d1, f
	goto	$+2
	decfsz	d2, f
	goto	$+2
	decfsz	d3, f
	goto	Delay_0

			;3 cycles
	goto	$+1
	nop

	retlw 0x00

	end
 

be80be

Well-Known Member
I have mclr pulled up with a 10 k I remove that line the led comes on and stays on
Maybe I need a night light. LOL. It will bink it just takes about 2 min to do so.
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
The only thing I can see strange is that the clock is set to 500kHz and so your delay is 8 seconds instead of 1 second.

Edit, You also have the bottom two bits of OSCCON set which is reserved! Just write 0x72 to OSCCON.

Mike.
 
Last edited:

be80be

Well-Known Member
In the data sheet it said high speed
Code:
START:
	banksel	OSCCON
	movlw b'0111111'
	movwf	OSCCON
that not right.
 

Pommie

Well-Known Member
Most Helpful Member
That is loading OSCCON with 0x3f which gives a 500kHz clock and a reserved operating mode. To do 0x72 in binary would be b'01110010'.

Mike.
 

be80be

Well-Known Member
I see you can't do it the way I thought I thought that as long as
111 bits 6-4
1 bit 3 = 1
1 bit 2 = 1
11 bits 1-0
11111111 and last one don't count.
Thanks I get it. dumie me
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
The bits are arranged MSB first I.E. 76543210.

So, to set bits 6, 5 & 4 to 1 you would do '01110000'

You can leave of leading zeros and so b'1001' is the same as d'9'.

Mike.
 

be80be

Well-Known Member
I locked this chip up with the wrong config did two that way turned LVP off and a pickit 2 will not want to program it. With out setting the chip to Vdd
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
PK2 should be able to blank a chip with LVP set. The only problem I know about is if you enable the timer1 oscillator as this uses the same pins as the ICSP. However, this can also be circumvented.

Mike.
 

be80be

Well-Known Member
Well I don't no what I did besides set LVP to off the code is the same but I turn LVP off. To get the chip to program. I had to set the programmer To use VPP frist program entry and set vdd on. Then It let me Blank the chip.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top