Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 23rd February 2007, 04:02 AM   (permalink)
Unhappy PIC 12F629 to PIC 12F683

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
e.chain is offline   Reply With Quote
Old 23rd February 2007, 04:50 AM   (permalink)
Default

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 is offline   Reply With Quote
Old 23rd February 2007, 12:58 PM   (permalink)
Default

Thanks a lot, will try ASAP.
e.chain is offline   Reply With Quote
Old 23rd February 2007, 07:09 PM   (permalink)
Default

Quote:
Originally Posted by Pommie
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 is offline   Reply With Quote
Old 23rd February 2007, 07:25 PM   (permalink)
Default

Quote:
Originally Posted by Papabravo
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 24th February 2007, 02:00 AM   (permalink)
Default

Quote:
Originally Posted by Papabravo
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"

Mike.
Pommie is offline   Reply With Quote
Old 25th February 2007, 03:41 AM   (permalink)
Default

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
e.chain is offline   Reply With Quote
Old 25th February 2007, 04:10 AM   (permalink)
Default

Why do you write TRISIO twice?
johnathan is offline   Reply With Quote
Old 25th February 2007, 04:14 AM   (permalink)
Default

Ooops, that was a mistake, I just left it there.
e.chain is offline   Reply With Quote
Old 27th February 2007, 01:50 PM   (permalink)
Default

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 by e.chain; 27th February 2007 at 01:52 PM.
e.chain is offline   Reply With Quote
Old 27th February 2007, 01:59 PM   (permalink)
Default

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.
Pommie is offline   Reply With Quote
Old 28th February 2007, 12:05 AM   (permalink)
Default

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.
e.chain is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
using 32768 crystal (12F629, 12F683) jimg Micro Controllers 26 3rd August 2008 02:35 AM
Most Common and Best PIC? LiquidOrb24 Micro Controllers 13 12th February 2007 02:42 AM
Good Pic Book Recomendations BackFire1 Micro Controllers 13 5th February 2007 10:20 PM
PIC 16F628A UART Coding Problem Gayan Soyza Micro Controllers 11 1st February 2007 11:58 AM
Newcomers, please read! (PIC regarded) Upd. 0xD Jay.slovak Micro Controllers 0 17th April 2005 01:04 PM



All times are GMT. The time now is 12:53 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.