Continue to Site

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.

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

Power up problem 16f870

Status
Not open for further replies.
Pic 16f870
4Mhz ats040 W/ 2-22mf 35v alum elec. capacitor (also tried W/ series res.)
5.3v input power
mclr tied to 5.3v (also tried with a 10m cap to ground)
Good grounds and power, no pins bent, built on a breadboard, all connections good
PortA not used (Tried connecting to ground)
PortB not used ( " " " " )

Portc inputs (7-4) - 4 normally open switches w/ 1k res. tied to ground
closed 5.3v
Portc outputs (3-0) - wired to 4 npn transistors controlling LEDS. (circuit works fine independently when applying 1.5v-5v to base.)
Sorry if the description is confusing I don't have a way to include a picture.

Programming with a picstart plus and mplab ide 7.5.

I've been trying to iron out all the details, finally got a good build with no errors and in the sim everything seems to work fine codewise, but when I burn the chip and put in the board , nothing happens:rolleyes:

I HATE to burden you guys with a newbies problem, but this is the only place I have to ask someone who knows first hand how to build one of these little buggers from the ground up!

I've hooked my Genisys scanner/scope to the oscillator pins but I don't see any activity (don't really know what to look for this is the first time I've tried to diagnose/look at a xtal oscillator signal. The scope reads down to 5us and 200mv.)

I'm really not confident enough in my PICing to rule out a code problem either though so here it is. ANY help at all would be greatly apprieciated.

Code:
	list		p=16f870	; list directive to define processor
	#include	<p16f870.inc>	; processor specific variable definitions
	
	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _CPD_OFF


;***** VARIABLE DEFINITIONS (examples)

; example of using Shared Uninitialized Data Section
INT_VAR		UDATA_SHR	0x71   
w_temp		RES     1		; variable used for context saving 
status_temp	RES     1		; variable used for context saving


; example of using Uninitialized Data Section
TEMP_VAR	UDATA_SHR	0x20		; explicit address specified is not required
temp_count	RES	1		; temporary variable (example)

;**********************************************************************
RESET_VECTOR	CODE	0x000		; processor reset vector
	movlw	high  start		; load upper byte of 'start' label
	movwf	PCLATH			; initialize PCLATH
	goto	start			; go to beginning of program


INT_VECTOR	CODE	0x04	; interrupt vector location
	movwf	w_temp			; save off current W register contents
	movf	STATUS,w		; move status register into W register
	movwf	status_temp		; save off contents of STATUS register


; isr code can go here or be located as a call subroutine elsewhere


	movf	status_temp,w		; retrieve copy of STATUS register
	movwf	STATUS			; restore pre-isr STATUS register contents
	swapf	w_temp,f
	swapf	w_temp,w		; restore pre-isr W register contents
	retfie				; return from interrupt


;VARIABLE REGISTERS=========================================================


SWTCHFLG	EQU		0X20
COUNT		EQU		0X21


;**********************************************************************
	
	clrf    PCLATH            ; ensure page bits are cleared
  	goto    main              ; go to beginning of program

main


	bsf			Status,5	;move to bank 1
	movlw		b'11111111'	;select as input
	movwf		trisA		;
	movlw		b'11110000'	;
	movwf		trisC		;
	movlw		b'00000000'	;
	movwf		trisB		;
	
	movlw		B'11010111'	;PB PULLUPS DISABLE,INT ON RISING EDGE, INTERNAL INSTRUCTION CYCLE CLOCK, INCR. ON LOWTOHIGH TRANS.,PRSC.TMR0, PRSC. RATE SELECT BITS= 1:256
	movwf		OPTION_REG

	bcf			status,5	;return to bank 0
	clrf		PORTA		;
	CLRF		PORTB		;
	clrf		PORTC		;
	clrf		INTCON		;DISABLE INTERRUPTS
	CLRF		SWTCHFLG
	CLRF		TMR0
	CLRF		COUNT

;POWER UP ROUTINE=====================
	BCF			STATUS,C
	movlw		B'00000001'
	MOVWF		PORTC
	CALL		DELAYP5
	RLF			PORTC
	CALL		DELAYP5
	RLF			PORTC
	CALL		DELAYP5
	RLF			PORTC
	CALL		DELAYP5
	RRF			PORTC
	CALL		DELAYP5
	RRF			PORTC
	CALL		DELAYP5
	RRF			PORTC
	CALL		DELAYP5
	CLRF		PORTC
	MOVLW		B'00001111'
	MOVWF		PORTC
	CALL		DELAYP5
	CLRF		PORTC
	CALL		DELAYP25
	MOVLW		B'00001111'
	MOVWF		PORTC
	CALL		DELAYP5
	CLRF		PORTC
	CLRF		TMR0
	CLRF		COUNT
	CLRF		W
	GOTO		START
;SUBROUTINES============================================================

;DELAY .25 SECOND

DELAYP25	CLRF		TMR0

			CLRF		COUNT
			MOVLW		D'4'
			MOVWF		COUNT

RESETP25	MOVLW		D'217'
			MOVWF		TMR0
LOOPP25		DECFSZ		TMR0
			GOTO		LOOPP25

DECCNTP25	DECFSZ		COUNT
			GOTO		RESETP25
			RETURN

;=======================================

;DELAY .5 SECOND

DELAYP5		CLRF		TMR0

			CLRF		COUNT
			MOVLW		D'9'
			MOVWF		COUNT

RESETP5		MOVLW		D'217'
			MOVWF		TMR0
LOOPP5		DECFSZ		TMR0
			GOTO		LOOPP5

DECCNTP5	DECFSZ		COUNT
			GOTO		RESETP5
			RETURN
				
;=======================================================================

START
		btfsc	PORTC,7	
		call	SWTCHON0
		btfsc	PORTC,6	
		call	SWTCHON1
		btfsc	PORTC,5	
		call	SWTCHON2
		btfsc	PORTC,4	
		call	SWTCHON3
		GOTO	START

SWTCHON0
		call	DELAYP25			;give switch time to stop bouncing
		btfss	PORTC,7		;check it's still pressed
		RETURN
		btfss	PORTC,0		;see if LED0 is already lit
		CALL	LED0ON
		CALL	LED0OFF
LED0ON
		bsf	PORTC,7		;turn LED0 on
REL0A	BTFSC	PORTC,0
		GOTO	REL0A
		GOTO	START	

LED0OFF
		bcf	PORTC,0		;turn LED0 off
REL0B	BTFSC	PORTC,7
		GOTO	REL0B
		GOTO	START

;
SWTCHON1
		call	DELAYP25			;give switch time to stop bouncing
		btfss	PORTC,6		;check it's still pressed
		RETURN
		btfss	PORTC,1		;see if LED1 is already lit
		CALL	LED1ON
		CALL	LED1OFF
LED1ON
		bsf	PORTC,1		;turn LED1 on
REL1A	BTFSC	PORTC,6
		GOTO	REL1A
		GOTO	START	

LED1OFF
		bcf		PORTC,1		;turn LED1 off
REL1B	BTFSC	PORTC,6
		GOTO	REL1B
		GOTO	START

;
SWTCHON2
		call	DELAYP25			;give switch time to stop bouncing
		btfss	PORTC,5		;check it's still pressed
		RETURN
		btfss	PORTC,2		;see if LED2 is already lit
		CALL	LED2ON
		CALL	LED2OFF
LED2ON
		bsf		PORTC,2		;turn LED2 on
REL2A	BTFSC	PORTC,5
		GOTO	REL2A
		GOTO	START	

LED2OFF
		bcf		PORTC,2		;turn LED2 off
REL2B	BTFSC	PORTC,5
		GOTO	REL2B
		GOTO	START

;
SWTCHON3
		call	DELAYP25			;give switch time to stop bouncing
		btfss	PORTC,3		;check it's still pressed
		RETURN
		btfss	PORTC,4		;see if LED3 is already lit
		CALL	LED3ON
		CALL	LED3OFF
LED3ON
		bsf		PORTC,3		;turn LED3 on
REL3A	BTFSC	PORTC,4
		GOTO	REL3A
		GOTO	START	

LED3OFF
		bcf		PORTC,3		;turn LED3 off
REL3B	BTFSC	PORTC,4
		GOTO	REL3B
		GOTO	START

	END                       ; directive 'end of program'
 
hotrodhed120 said:
Pic 16f870
4Mhz ats040 W/ 2-22mf 35v alum elec. capacitor (also tried W/ series res.)

Are you saying that the 2 capacitors connected to the crystal are 22 microfarad?
If so then that is the problem, they should be 22pF (picofarad)
 
picasm said:
Are you saying that the 2 capacitors connected to the crystal are 22 microfarad?
If so then that is the problem, they should be 22pF (picofarad)

Oh. Great. I'll try that later tonight and let you know.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top