Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic16f88 not working properly

Status
Not open for further replies.

amitaiwe

Member level 3
Member level 3
Joined
Feb 19, 2014
Messages
57
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Visit site
Activity points
547
Hi,
I want to implement a project using the PIC16F88.
As a start and for needed indications later a want to lit up a led
and it doesn't work properly
I'm using a PICKIT3 for programing, and I have managed to program a PIC16F877
for another program.

I tried various variations of turning on/off and flickering led commands.
In all the cases the led (bi-colored) responded after a long time (~30 sec)
and turned off and on randomly. The mplab software messages inform
of no errors and of successful programing.
The led works well when not connected to the PIC.

What can the problem by?
I'm attaching the recent code
Thanks, Amitai

Code:
LIST	P=PIC16F88
    	
include	<P16f88.inc>
org		0x00

	__CONFIG _CONFIG1, _LVP_OFF &_WDT_OFF &_PWRTE_OFF &_CP_OFF & _INTRC_IO

	reset:
	nop
	goto	start
	org		0x20

start:

; CONFIGURATION*-*-*-*-*-*-*-*-*-
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

; used_ registers:
	MUX_sel			EQU H'0021'  		; MUX select value
	del1			EQU H'0030'  		; for delay
	del2			EQU H'0031'  		; for delay
	to_transmit		EQU H'0050'  		; data register
	led1			EQU H'0070'  		; for led delay
	demo_tr			EQU H'0072'  		; demo transmit
	loop_mux		EQU H'0074'  		; demo transmit
	
; oscillator
	banksel		OSCCON					; 8M internal clk, mode defined 
	movlw		0b01110100					; by fosc(2:0), ??????
	movwf		OSCCON					; system clock source from main oscillator 

; led
	BANKSEL 	PORTB ; select bank of PORTA
	CLRF		PORTB ; Initialize PORTA by
	
	banksel		ANSEL					; Configure all pins as digital inputs	
	clrf		ANSEL				
	banksel		TRISB
	clrf		TRISB					; make PORTB output

; MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Led_flicker:
	banksel		PORTB
	bsf			PORTB,3	
	bcf			PORTB,2
;---end Led flicker

; END MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

end
 

I have no idea what you are trying to do here. You set bit 3 of portb, then you clear bit 2 of portb and then I think your program just runs off into the woods.
 

I have no idea what you are trying to do here. You set bit 3 of portb, then you clear bit 2 of portb and then I think your program just runs off into the woods.

I'm aware of that. As I wrote, I have done a few test with different
options for the led and non of them changed.
I can reverse one of the versions:

Code:
LIST	P=PIC16F88
    	
include	<P16f88.inc>
org		0x00

	__CONFIG _CONFIG1, _LVP_OFF &_WDT_OFF &_PWRTE_OFF &_CP_OFF & _INTRC_IO

	reset:
	nop
	goto	start
	org		0x20

start:

; CONFIGURATION*-*-*-*-*-*-*-*-*-
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

; used_ registers:
	MUX_sel			EQU H'0021'  		; MUX select value
	del1			EQU H'0030'  		; for delay
	del2			EQU H'0031'  		; for delay
	to_transmit		EQU H'0050'  		; data register
	led1			EQU H'0070'  		; for led delay
	demo_tr			EQU H'0072'  		; demo transmit
	loop_mux		EQU H'0074'  		; demo transmit
	
; oscillator
	banksel		OSCCON					; 8M internal clk, mode defined 
	movlw		0b01110100					; by fosc(2:0), ??????
	movwf		OSCCON					; system clock source from main oscillator 

; led
	BANKSEL 	PORTB ; select bank of PORTA
	CLRF		PORTB ; Initialize PORTA by
	
	banksel		ANSEL					; Configure all pins as digital inputs	
	clrf		ANSEL				
	banksel		TRISB
	clrf		TRISB					; make PORTB output

; MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Led_flicker:
	banksel		PORTB
	bsf			PORTB,3	
	bcf			PORTB,2
        CALL                 DELAY
        bsf			PORTB,2	
	bcf			PORTB,3
        goto                  Led_flicker
;---end Led flicker

; END MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DELAY:
	movlw		0xFF
	movwf		del1
	movlw		0xFF
	movwf		del2
	
	loopa:
	decfsz		del1, f
	goto		loopa
	loopb:
	decfsz		del2, f
	goto		loopb
	return

end

Amitai
 

Hi,


Your code put back in to order with a Delay routine - you should be able to follow things from the comments I have added.

The picture shows the program running, you just need to add Vdd and Vss to your chip and it should work.

These tutorials should help you do more ..


**broken link removed**
http://www.winpicprog.co.uk/pic_tutorial.htm
http://www.amqrp.org/elmer160/lessons/
http://www.epemag.wimborne.co.uk/resources.htm



Code:
	LIST	P=PIC16F88
    	
	include	<P16f88.inc>
	org		0x00



; CONFIGURATION*-*-*-*-*-*-*-*-*-
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

	__CONFIG _CONFIG1, _LVP_OFF &_WDT_OFF &_PWRTE_OFF &_CP_OFF & _INTRC_IO & _MCLRE_OFF


; user_ registers:
	cblock 0x20
	MUX_sel		  		; MUX select value
	del1		 		; for delay
	del2				; for delay
	to_transmit			; data register
	led1		 		; for led delay
	demo_tr				; demo transmit
	loop_mux			; demo transmit

	d1,d2,d3			; delay work files
	
	endc



reset:
	nop
	goto	start
	org		0x20

start:


	
; oscillator				; 8M internal clk, mode defined 
	movlw		b'01110100'			
	movwf		OSCCON					; system clock source from main oscillator 

; led
		
	banksel		ANSEL					; Configure all pins as digital inputs	
	clrf		ANSEL	
	BANKSEL 	PORTB					 ; select bank of PORTA
	CLRF		PORTB 					 ; Initialize PORTA by
			
	banksel		TRISB
	clrf		TRISB					; make PORTB output

; MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Led_flicker:							; FLASH A LED ON AND OFF RB3
	banksel		PORTB
	bsf			PORTB,3					; turn on led
	call		delay500ms				; delay 1/2 second 
	bcf			PORTB,3
	call		delay500ms				; delay 1/2 second

	goto		Led_flicker				; return to start of the loop
;---end Led flicker


; SUB ROUTINES*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*



delay500ms								; based on 8mhz oscillator
	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

    return


; END MAIN PROGRAM*-*-*-*-*-*-*-*-*-*
;*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

end
 

Attachments

  • 000113.jpg
    000113.jpg
    18.3 KB · Views: 63

I still don't understand what you're doing with those two port pins. Why are you toggling two pins? Maybe we need to see your schematic.
 

I still don't understand what you're doing with those two port pins. Why are you toggling two pins? Maybe we need to see your schematic.

Hi,

Like you say he needs to explain the parts he is actually using plus a schematic.

Assume he is trying to do as the pics show, but I just gave him the working single flasher code so he could hopefully progress further himself.
 

Attachments

  • 000114.jpg
    000114.jpg
    18.9 KB · Views: 69
  • 000115.jpg
    000115.jpg
    18.4 KB · Views: 65

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top