pic 12F675 issue

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,

I've just been reading through a few other posts to see if I can sort myself out.... I've some pic12f675's lying about that I wanted to use for a project that uses the comparator, I remember I gave up on them a few years ago when I was using a Picstart plus. I've now been using a pickit2 which is about a thousand times better.

Anyway I dug out the 12f675's and wrote a very short programme to flash a LED on gpio,5 with the pickit2 powering the chip I got my led to flash:).

I then added power via my bench supply, the led still flashed so I went about programming it for my application (ir beam break). It was fine now nothing, I've gone back to the start again and none of the four I have will work?

Could I have cooked them previously? Experiance has so far told me pics are quite tough. It appears to me as if they arn't starting up.

Details; Circuit, very simple, decoupling cap, 5v regulated supply
One resistor, one LED
ICP header.

Configuration; Internal osc, no clock out
Powerup timer on
WDT off
Brown out off
MCLR off
Code protect off

Has anyone else had trouble with these? Any ideas or shall I just buy new ones!

Thanks Geoff
 

tshuck

Joined Oct 18, 2012
3,534
Please post your code. A schematic, no matter how trivial may also help. Sometimes, that's where you realize a mistake.
 

hexreader

Joined Apr 16, 2011
581
I half remember that PICkit2 and 12F675 have issues with losing the OSCCAL value.

Remove the calibration call from the start of your program (I am guessing that you are using assembly language). Your timing will be inaccurate, but your code will run.

If you plan to buy buy new chips, buy 12f683 or newer. PIC12f683 is factory calibrated and there is no issue with oscillator calibration.

Search the Microchip archive if you want real facts that do not rely on my failing memory.

My guess is that your PICs are not faulty, but just need OSCCAL value re-generated.

EDIT: better still, ask the same question on the Microchip forum
 

tracecom

Joined Apr 16, 2010
3,944
I half remember that PICkit2 and 12F675 have issues with losing the OSCCAL value.

Remove the calibration call from the start of your program (I am guessing that you are using assembly language). Your timing will be inaccurate, but your code will run.

If you plan to buy buy new chips, buy 12f683 or newer. PIC12f683 is factory calibrated and there is no issue with oscillator calibration.

Search the Microchip archive if you want real facts that do not rely on my failing memory.

My guess is that your PICs are not faulty, but just need OSCCAL value re-generated.

EDIT: better still, ask the same question on the Microchip forum
I bet your diagnosis is correct. The late versions of the PICkit2 Programmer software have an OSCCAL regen function, but I don't know if it works on the 12F675.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Wow, thanks for the swift replys, I knocked out the osccal write but they're still not playing!
Here's my schematic

12f675.gif

And my code;

Rich (BB code):
#INCLUDE P12F675.INC
	LIST P=12F675
	ORG	 0X00
	GOTO	START

__CONFIG_INTRC_ORC_NOCLKOUT_WDT_OFF_PWRTE_ON_MCLRE_OFF_BOREN_OFF_CP_OFF_CPD_OFF
	
	COUNT	EQU	0X20
	TIME	EQU	0X21
;#########################################################
DELAYP5	MOVLW	.100
		MOVWF	COUNT
TIMED	CALL	DELAY
		DECFSZ	COUNT
		GOTO	TIMED
		RETLW	0

DELAY	CLRF	TMR0
LOOPA	MOVF	TMR0,W
		SUBLW	.39
		BTFSS	STATUS,Z
		GOTO	LOOPA
		RETLW	0

DELAY1.5	CLRF	TMR0
LOOPB		MOVF	TMR0,W
			SUBLW	.10
			BTFSS	STATUS,Z
			GOTO	LOOPB
			RETLW	0
 

START BSF	STATUS,5	;BANK1

	CLRF	ANSEL

;	CALL	3FFH
;	MOVWF	OSCCAL
	MOVLW	B'00001011'	;GP0, GP1 COMPARATOR INPUT REST OUTPUT
	MOVWF	TRISIO
	MOVLW	B'00000111'
	MOVWF	OPTION_REG
	BCF		STATUS,5	;BANK0

	MOVLW	0X07		;	
	MOVWF	CMCON

	CLRF	GPIO

;############################################


BEGIN	BSF		GPIO,5
		CALL	DELAYP5
		BCF		GPIO,5
		CALL	DELAYP5
		GOTO	BEGIN

END
Thanks for looking, its bugging me!:confused::confused:
 

Markd77

Joined Sep 7, 2009
2,806
Not sure if this really causes a problem, but you are supposed to do a "clrwdt" before changing prescaler to TMR0 (section 4.4 of datasheet)
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks, just tried that to no avail!!! Darn it. The programming is always reported as successful, I've got a 100nF decoupling cap, is that what other folks use?
Cheers Geoff
 

RG23

Joined Dec 6, 2010
304
Comment the config line of your code

Instead in MPLAB use the configuration bits set in code and try to build the program

If it builds successfully program your PIC with pickit2

Disconnect the pickit2 and run your unit
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks for the replies, 39 isn't subtracted from 100, it counts 39 cycles of tmr0, 100 times? for a nice long delay, the led should at least light up.

Just rebuilt it setting config bits in mplab and it goes! Thank you, I'm now really curious as to why it worked and then didn't?

As I was writing I felt a need to tinker, changed my config code to;

Rich (BB code):
__CONFIG_INTRC_ORC_NOCLKOUT
__CONFIG_WDT_OFF_
__CONFIG_PWRTE_ON
__CONFIG_MCLRE_OFF
__CONFIG_BOREN_OFF
__CONFIG_CP_OFF
__CONFIG_CPD_OFF
Rebuilt it with config set in code and it works. I'm pleased but puzzled?:confused:

Thanks again Geoff
 

THE_RB

Joined Feb 11, 2008
5,438
If the config is programmed wrong (or is missed) then the PIC might expect a xtal, and it won't run without the xtal.

So even though your code is expecting the internal oscillator to run, the programmed PIC won't run.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks for the reply, the bit that puzzles me is that in worked to start with? I changed nothing in the config,and it stopped. Sort of an aside what is the approved convention for configuring a PIC? I'm self taught and have seen various ways of doing it? The first book I read suggested setting the 'fuses' in mplab configure section then reading the number and putting __config'xxxx' ie what ever the number was.

This seemed a bit muddly I've tried the way I did it this last bit of code a few times but it seems to have gone wrong this time?

I guess I could be opening a can of worms?!

Cheers Geoff
 

ErnieM

Joined Apr 24, 2011
8,377
Sort of an aside what is the approved convention for configuring a PIC?
I can't say why it worked, then didn't work, then worked. Could be as simple as not noticing MPLAB not saying "Build successful!" at the end because of some other minor thing.

I've always put the config information into the code, usually near the top of the main dot C file, the one that holds main(). Microchip uses this same area. The big advantage over putting inside MPLAB is you have more control as you can use conditional compilation to change configs for whatever reason (but usually different PICs).

I'm self taught too, I've just been at this for a longer time. <grin>
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks I shall do that! One thing I've learnt is pic's always do what you tell them! If their not doing what you expect its your fault!:)
Thanks for everyones help Geoff
 
Top