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.

16f628a

Status
Not open for further replies.

RMIM

Member
HI,

Please can someone help me breathe some life in my PIC 16F628A.

I have been reading about them for a short time now. I have understood (I think) things like TRISA TRIAB PORTA PORTB., DECFSZ, MOVLW, binary no. hex no. etc.

Today I actually received my 16F628A and a programmer that claims to be MPLAB compatible (works as PicStart Plus)
**broken link removed**

I have been fighting with it all day trying to get just a peep out of it – I was really struggling with it in MPLAB. It seems to fail often when writing to it. Refused to erase.

After a few hours of disappointment I found the problem – I had selected 16F628 and not 16F628**A**!!! It seems to work in MPLAB fine now.

But I still cound not get a peep out of it in my circuit.

Im tired from fighting with it. Please can someone spoon feed me and give me the header etc. how to select the internal oscillator/ what I need on my external circuit. Set all PORTB to outputs as I want to flash some LED’s on PORTB. Any little things I need to do in MPLAB (watchdog setting etc.)

I have been using the following as a guide
(PIC 16F628, scroll down)
I could not find 4.7k ohm resistor so I used a 6k one – does that matter?
Also I bought a ZIF for my bread board – are the pins long enough to make proper contact? They seems a bit short and I could not read a voltage between pins 5 and 14. Turn it the other way round started to work. Will sanding down the little round feet help?
Could someone modify the following for a 16F628A and get pins RB4 to RB7 to flash or give out logic1. so I know all is working then I can take it from there -
Code:
;***************************************************************
	title	"PIC Sample code: PIC16F628 program"
	subtitle	"Version 1.0 (c) Jay.slovak"
;Designed for 16F628 @4Mhz
;***************************************************************
	list	p=16F628
	#include	<p16F628.inc>
	__CONFIG	_CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF
	ERRORLEVEL -302
;***************************************************************
z1	equ	2Ah
z2	equ	2Bh
z3	equ	2Ch
z4	equ	2Dh
;***************************************************************
	org	0x0000
	goto	INIT
	NOP
	NOP
	NOP
	NOP
	org	0x0005
INIT	MOVLW	H'07'
	MOVWF	CMCON
	CLRF	PORTA
	CLRF	PORTB
	BSF	STATUS,RP0	;Select Bank 1
	CLRF	TRISA	;Port A is output
	CLRF	TRISB	;Port B is output
	BCF	STATUS,RP0	;Select Bank 0

Start	MOVLW	0xFF
	MOVWF	PORTA
	MOVWF	PORTB
	CALL	Delay
	CLRF	PORTA
	CLRF	PORTB
	CALL	Delay
	GOTO	Start
;***************************************************************
;***************************************************************
	subtitle	"Delay subprogram"
Delay	movlw	D'3'
	movwf	z3
	movlw	D'137'
	movwf	z2
	decfsz	z1,f
	goto	$-1
	decfsz	z2,f
	goto	$-3
	decfsz	z3,f
	goto	$-5
	return
	
	END
;***************************************************************
 

Attachments

  • Picture.jpg
    Picture.jpg
    129.4 KB · Views: 240
Last edited:
Hi there,

Try checking the 'Low Voltage Program' in the config. If its 'Enabled' Disable it.

I have had this problem before where the PIC just sits there doing nothing.

Hope this helps

Regards
Pete
 
change your return to RETLW 0

The LVP mode is already disabled but try to change your CONFIG line to this one
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF

i tested your code with the above suggestion and it works.
 
Last edited:
mister_e said:
change your return to RETLW 0

Why would you want to do that?, RETLW is the only 'return' available on 12 bit PIC's, but the 14 bit 628 also has the 'RETURN' instruction - in this case neither would make the slightest bit of difference.
 
mister_e said:
change your return to RETLW 0

The LVP mode is already disabled but try to change your CONFIG line to this one
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF

i tested your code with the above suggestion and it works.

OH MY GOD!!!!!!!!! - it works!
I could not believe it so I went back and changed it to the original (_MCLRE_ON) it stopped working. Changed back again and it worked. - You have saved me a lot of time and heart ache.

If anyone would like to explain the -MCLRE_ON/OFF that would be useful.

Thanks once again mister_e
 
Mike said:
MCLR_ON requires the pull-up resistor. Perhaps you didn't install that 6K0 pull-up?

Mike
You hit the nail on the head – I plugged the other end of my 6k resistor in the –ve line not positive, damn those bread board holes are so close!

I changed the code back to the original and it works with that one too now.

Thanks Mike.
 
RMIM said:
Im tired from fighting with it.

;) We all know that 1! Next time, give it a few more mins, have a cup of T, kick it around the room, and come back to it, you will find the problem. It's nearly ALWAYS the simple probs that get you (wire in -ve instead of +ve) ;)

You have been officially bitten by the PIC bug, no escape now ;)
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top