![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
Thanks a lot, will try ASAP.
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
Mike. |
||
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
Why do you write TRISIO twice?
|
|
|
|
|
|
|
(permalink) |
|
Ooops, that was a mistake, I just left it there.
|
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
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.
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| 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 |