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.

ARGH! PIC12F629 help please =D

Status
Not open for further replies.
To add to the confusion, some of the 12F series are 14 bit and some 12 bit(12F508). Microchip further add to the confusion by issuing one data sheet which covers PIC12F508/509/16F505, which are all 12 bit.

So, add to Nigel's list,
16F series - 12 bit.

Mike.
 
gramo said:
The lowly 629 and every other 16F PIC have so many fundamental programming issues, I'm surprised they are still in use...
Do you have facts to back up this statement, or, is this just another Gramo lamo opinion?

Perhaps it's YOU that have "fundamental programming issues" with 12F' and 16F' devices?
 
Payment
Mike said:
Do you have facts to back up this statement, or, is this just another Gramo lamo opinion?

Perhaps it's YOU that have "fundamental programming issues" with 12F' and 16F' devices?


You’re just leading this further off topic! The 16F and 18F PIC comparison has been done that many times... Just Google it if you have that short a memory

:rolleyes:
 
gramo said:
The lowly 629 and every other 16F PIC have so many fundamental programming issues, I'm surprised they are still in use...

18F PIC's are not harder to use. Don’t get caught in this fallacy! They are 16F’s without any of the downfalls


Here's a quote from the Swordfish site;

The 10, 12 & 16 series PICs are great little chips, there is nothing wrong with them and billions of them have found their uses around the world. They were just not designed with compilers in mind.

Actually aside from bank switching and Read Modify Write they are not hard to program.
 
gramo said:
Payment


You’re just leading this further off topic! The 16F and 18F PIC comparison has been done that many times... Just Google it if you have that short a memory

:rolleyes:

Whos leading off topic? Surely not you Gramo, If I asked you what your favourite color is would the answer be a PICKIT2 with Proton, swordfish?

The original question was about the 12F629 and a JDM programmer with some code in assembler. Somehow you got swordfish in the mix, are you on commision?
 
Hey there,

Still havent got this chip to blink yet !!


I think it has something to do with the internal RC ..


What voltages should the pins of chip have during programming?

I checked VDD and VSS and they are @ 5 and 0v, respectively.

What about the others? (pins)

I think that the programmer is ok though because I am able to save the code on the pic and then 'read' it back to IPROG.

Could someone possibly supply the schematic for wiring the chip for either XTAL or RC oscillating?

Because I really think the internal RC is completely messed up!

That way I can check if the chip is atleast understanding the code.

If you have the code I would be very grateful.. no need to go out of your way though :D

Just want to set it up for 4mhz XTAL (peripherial)

And blink all outputs (except for GPIO3 of course) @ 1hz so that I can verify the chip is not fried.

Take Care,
PW

P.S: Again I am going to have to decline SwordFish, Gramo. Maybe someday in the near future you will convert me.. but until then...

I will probably use a higher level language once I feel I have mastered assembly.. but I feel that will take many many years.
 
Last edited:
To change the Oscillator, change the setting in the config line from _INTRC_OSC_NOCLKOUT to either _EXTRC_OSC_NOCLKOUT or for a 4MHz crystal, _XT_OSC.

The circuit diagrams for the oscillator are on pages 53 and 54 of the datasheet.

Mike.
 
blueroomelectronics said:
Whos leading off topic? Surely not you Gramo, If I asked you what your favourite color is would the answer be a PICKIT2 with Proton, swordfish?

Please...

And what’s your favorite color Bill? Unicon USB Experimenter & Inchworm+ Upgrade? Want to buy a Mongoose with that? Are you on a commission, o no wait, your entitled to your recommendations because you own the products... whatever man, I'm tired of this old school debate.

It's a public forum, be prepared for public responses.

The original question was about the 12F629 and a JDM programmer with some code in assembler. Somehow you got swordfish in the mix, are you on commission?

Hell no, I'd love to be a beta tester though! But seriously, everyone deserves to know what else is out there.

The world extends further than bit banging assembly & over priced wannabe breakout boards.



:rolleyes:
 
gramo said:
Please...

And what’s your favorite color Bill? Unicon USB Experimenter & Inchworm+ Upgrade? Want to buy a Mongoose with that? Are you on a commission, o no wait, your entitled to your recommendations because you own the products... whatever man, I'm tired of this old school debate.

It's a public forum, be prepared for public responses.



Hell no, I'd love to be a beta tester though! But seriously, everyone deserves to know what else is out there.

The world extends further than bit banging assembly & over priced wannabe breakout boards.

:rolleyes:

When asked about a good PIC programmer I recommend mine of course, and yes I make a comission as it's what I do. I design kits that I'd like to use/buy myself. I don't try to hard sell like you and why? It's like a religion to you, if someone wants to flash an LED you recommend a commercial BASIC compiler.
Why learn assembly, too much work? might have to study? Many people here are trying to learn something new and take off the training wheels.
Nothing teaches the inner workings of any micro better than learning a little assembly language.
A 14bit PIC has 35 instructions, most people can wrap their minds around it with a little guidance.

PS we all have our soapbox, you it BASIC & Proton and recently the PICKit2, MikeK8LH it's 1N7000 fets, Nigel assembly.
As for me well where to start I like Sketchup, iButtons/1-Wire I think they're amazing, RS485 (you'll see it on many of my new designs) and PICs. I don't dislike BASIC, C or whatever, nor will I answer an Atmel question with a PIC response (unless it's an Atmel vs PIC question).

As for the Mongoose sure it's a simple robot chassis, theyre are hundreds of em. And they tend to stay in the robotics section, and I hope to sell scads of them. I thought it would be interesting to some folks to post the progress of the chassis, it's been through a dozen or so changes thanks to the suggestions by people on the forums here and is shaping into a hopefully nice kit.

And you're right it's a public forum.
 
Peter, try this. Hook up your 12F629 just like the 12F509 shown in the poster below (it's a PDF file)

Code:
 ;*** WDT reset toggles GP2
  list     p=12F629
  include <p12F629.inc>
  __CONFIG 0x3FBC
  org      0
  movlw    b'00001110'
  option
  movlw    b'11111011'
  tris     GPIO
  movlw    b'00000100'
  xorwf    GPIO, f
  sleep
  end
And buy my programmer ;)
 
Last edited:
WOOOOOOOOOOOOOOOOOT!!!!!!!!!!!!!!!!!!!!!!

Thanks so much Mike!


Finally some blinkage!


Here is the code I used:

HTML:
;**********************************************************************
list      p=12f629
#include <p12f629.inc>
errorlevel  -302
__CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;**********************************************************************		

cblock	0x22
Count
Count2
endc

w_temp        EQU     0x20
status_temp   EQU     0x21
;**********************************************************************
ORG     0x000             ; processor reset vector
goto    main              ; go to beginning of program

ORG     0x004             ; 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

; int 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

; these first 4 instructions are not required if the internal oscillator is not used
main
;call    0x3FF             ; retrieve factory calibration value
;bsf     STATUS,RP0        ; set file register bank to 1 
;movwf   OSCCAL            ; update register with factory cal value 
;bcf     STATUS,RP0        ; set file register bank to 0
movlw	0x07		;turn comparators off
movwf	CMCON
bsf	STATUS,RP0
movlw	b'00000000'	;0 = input
movwf	TRISIO
bcf	STATUS,RP0
movlw	0x55
movwf	GPIO

Loop	
movlw	0xff
movwf	GPIO
call	Delay
clrf	GPIO
call	Delay
goto	Loop

Delay		
movlw	0x02
movwf	Count2
movlw	0
movwf	Count
DelLoop		
addlw	1
btfss	STATUS,Z
goto	DelLoop
decfsz	Count,F
goto	DelLoop
decfsz	Count2,F
goto	DelLoop
return

org	0x3ff
retlw	0x80

ORG	0x2100
DE	0x00, 0x01, 0x02, 0x03

END

Now If I can just get this program to work with the internal OSC I think we're in business!

Take Care,
PW
 
Aw..

I messed it up again!!

The "Oscillator Calibration Value" was 3020H and I was able to program and read the chip..

When I tried to load up one of Mikes program it asked "Do you want to set the "Oscillator Calibration Value" to (3480H)" I said Yes then I got the IPROG error message (Fun Fun :| )

Now the it (iprog) tells me " NO "Oscillator Calibration Value" found.. would you like to use value from file (3480H)? If I chose yes I get the error if I choose no I get the error!

If I used the code which placed 3020H in I also get the error!

what the heck is going on here :mad:
 
houston we have lift off.

Alright Got it to blink with internal CLK - FINALLY :p

Here is the code:

HTML:
;**********************************************************************
list      p=12f629
#include <p12f629.inc>
errorlevel  -302
__CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT 
;**********************************************************************		
;_XT_OSC
cblock	0x22
Count
Count2
endc

w_temp        EQU     0x20
status_temp   EQU     0x21
;**********************************************************************
ORG     0x000             ; processor reset vector
goto    main              ; go to beginning of program

ORG     0x004             ; 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

; int 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

; these first 4 instructions are not required if the internal oscillator is not used
main
call    0x3FF             ; retrieve factory calibration value
bsf     STATUS,RP0        ; set file register bank to 1 
movwf   OSCCAL            ; update register with factory cal value 
bcf     STATUS,RP0        ; set file register bank to 0
movlw	0x07		;turn comparators off
movwf	CMCON
bsf	STATUS,RP0
movlw	b'00000000'	;0 = input
movwf	TRISIO
bcf	STATUS,RP0
movlw	0x55
movwf	GPIO

Loop	
movlw	0xff
movwf	GPIO
call	Delay
clrf	GPIO
call	Delay
goto	Loop

Delay		
movlw	0x02
movwf	Count2
movlw	0
movwf	Count
DelLoop		
addlw	1
btfss	STATUS,Z
goto	DelLoop
decfsz	Count,F
goto	DelLoop
decfsz	Count2,F
goto	DelLoop
return

org     0x3ff
movlw   0x20


ORG	0x2100
DE	0x00, 0x01, 0x02, 0x03

END
 
I'm not sure why that code is working since you've got a MOVLW 0x20 at address 0x3FF. It needs to be a RETLW since you use a CALL 0x3FF.

If you use the programmer to read the code back out of that PIC, what value is at program memory address 0x3FF?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top