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.

PIC 12F629 to PIC 12F683

Status
Not open for further replies.

e.chain

New Member
Hello to all, I hope someone could help me with this I've been trying to pass this asm settings from Pic 12F629 to 12F683 with no success, so please I need help.

BCF STATUS,RP0 ; SEL BANK 0
MOVLW 0X07
MOVWF CMCON ; DISABLE COMPARATOR ON GPIO PINS
BSF STATUS,RP0 ; SEL BANK 1
CALL 0X3FF ; CALLS RETLW WITH FACTORY SETTING
MOVWF OSCCAL ; SET INT OSC TO FACTORY CALIBRATED
MOVLW B'00001111' ; SET WDT PRESCALER = 1:128 (F_OSC=4MHZ) AND WEAK PULL UPS ENABLE
MOVWF OPTION_REG
MOVLW B'00000010'
MOVWF WPU ;SET PULL UP IN GP1 ONLY
MOVLW B'11001010' ;SET GPIO: 0,2,4,5 OUTPUT
MOVWF TRISIO ;SET GPIO: 1,3 (PINS 6,4) INPUTS
MOVWF TRISIO
BCF STATUS,RP0 ;SEL BANK 0
BTFSS STATUS,NOT_TO ;WAS THERE AN WDT RESET?
GOTO WDTREFRESH ;YES, KEEP BOX ALIVE
GOTO START ;NOPE, LETS GO START MAIN PROGRAM
 
The first thing that is going to cause a problem is the call 0x3fff as there is no return instruction in the 683. Just remove it and the next line. Other things are CMCON should by CMCON0 and you need to insert a clrf ANSEL.

When you tidy it up, repost it using the code tags (on the advanced page).

Mike.
 
Pommie said:
The first thing that is going to cause a problem is the call 0x3fff as there is no return instruction in the 683. Just remove it and the next line. Other things are CMCON should by CMCON0 and you need to insert a clrf ANSEL.

When you tidy it up, repost it using the code tags (on the advanced page).

Mike.
Just to eliminate a small ambiguity. The 12F683 architecture supports the RETURN, and the RETLW, and the RETFIE, it's just that location 3FFF doesn't automatically contain any specific instruction. AFIK it's blank just like the rest of the program memory locations. Is this what you meant?
 
Papabravo said:
Just to eliminate a small ambiguity. The 12F683 architecture supports the RETURN, and the RETLW, and the RETFIE, it's just that location 3FFF doesn't automatically contain any specific instruction. AFIK it's blank just like the rest of the program memory locations. Is this what you meant?

Blank memory reads as a NOP, so the PC will loop round and call the same 'non-existent' address repeatedly - obviously the stack will overflow, and the program can never run.
 
Papabravo said:
Just to eliminate a small ambiguity. The 12F683 architecture supports the RETURN, and the RETLW, and the RETFIE, it's just that location 3FFF doesn't automatically contain any specific instruction. AFIK it's blank just like the rest of the program memory locations. Is this what you meant?

Yes, perhaps I should have said "as there is no return instruction at that address" :eek:

Mike.
 
Ok here it is, this is what I did and it is working perfectly as expected, thanks to all.

Code:
DISPATCH_INTERNALINIT
 CLRF   GPIO
 BCF    STATUS,RP0      ; SEL BANK 0
 MOVLW  0X07      	 
 MOVWF  CMCON0    	      ; DISABLE COMPARATOR ON GPIO PINS
 BSF    STATUS,RP0      ; SEL BANK 1
 CLRF	ANSEL
 MOVLW  B'01100111'	; 4MHZ
 MOVWF  OSCCON
 MOVLW  B'00000000'     ; DEFAULT CALIBRATION
 MOVWF  OSCTUNE
 MOVLW  B'00001111'     ; SET WDT PRESCALER = 1:128 (F_OSC=4MHZ) AND  WEAK PULL UPS ENABLE  
 MOVWF  OPTION_REG
 MOVLW  B'00000010'
 MOVWF  WPU             ;SET PULL UP IN GP1 ONLY
 MOVLW  B'11001010'     ;SET GPIO: 0,2,4,5  OUTPUT
 MOVWF  TRISIO		;SET GPIO: 1,3 (PINS 6,4) INPUTS
 MOVWF  TRISIO
 BCF	  STATUS,RP0      ;SEL BANK 0
 BTFSS  STATUS,NOT_TO   ;WAS THERE AN WDT RESET?
 GOTO   WDTREFRESH      ;YES, KEEP BOX ALIVE
 
I have a doubt with this PIC, the first PIC I've programmed I did it by mistake without the OSCCON register and then everytime I try to reprogram the PIC with this register in the asm it doesn't work properly, sometimes it will work and sometimes not, the other one was done with the OSCCON register in the asm and this one is working properly and I've erased lots of time but everytime I program the chip works correctly. I don't know, maybe these PICS are a bit delicate or Am I doing something wrong on the Setup, I just want the PIC to work at 4MHZ and maybe I don't think I need to use the OSCTUNE register for this. Please anybody can help?
 
Last edited:
You are writing zero to OSCTUNE. This is the default value and therefore you are not changing anything. I think your problem is elsewhere.

Mike.
P.S. No, you don't need to write to OSCTUNE.
 
You were totally right on this Pommie, it was a GOTO instruction that was causing this issue on the PIC, also changed the setup from the bottom line to ORG 0X00 in the upper part and it is working more accurate. Thanks again.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top