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.

Pic12f629 Ports Problem.

Status
Not open for further replies.

bitem2k

New Member
Hi, Ive turned off the Comparator module on the 629,
changed trisio to 0x00,
and now i can change the first 3 bits of GPIO register to 1.
I know you cant use GP3 as an output, but I still cant change GP4 or GP5 bits of the GPIO register to 1.

Ive searched the datasheet for ages, but I cant seem to find anything else to turn off, to allow me to use GP4 and 5:mad:.

Any ideas?
 
Ive just burned the program onto the pic, and it works!
For some reason MPLAB SIM is not letting me change the register, but the Actual PIC will.

Any ideas?
 
You can create a Simulation file. The instructions can be found using Help->MPLAB Sim. I never use them, can I get confirmation from someone here?

Where and when are you attempting to change the register? During the sim debug (F7) wait till the trisio is completed (or after the port pin is an Output). Also when using the SFR View box, add a Binary column to the table and change the exact GP bit


Edit:
This worked another device. I have same issue with 12629.
 
Last edited:
Your ports input/output selecting routine must like this after switching to bank1 & before calling OSCCAL value if have.

Code:
	movlw	b'001000'	;GP3 input
	movwf	TRISIO

To make all outputs high except GP3

Code:
	movlw	b'110111'
	movwf	GPIO

dont set bits like this continuously

Code:
	bsf	GPIO,4
	bsf	GPIO,5
do like this
Code:
	movlw	b'110000'	;turn ON bit 4 & 5
	movwf	GPIO
 
yes I had done all that, still gives incorrect reading in sim.
Oh well, cant be arsed anymore.

thanks anyway.
 
I suspect that you havn't told MPLAB that you want to use the internal oscillator. Try changing the config settings.

Mike.
 
donniedj said:
You can create a Simulation file. The instructions can be found using Help->MPLAB Sim. I never use them, can I get confirmation from someone here?

Where and when are you attempting to change the register? During the sim debug (F7) wait till the trisio is completed (or after the port pin is an Output). Also when using the SFR View box, add a Binary column to the table and change the exact GP bit


Edit:
This worked another device. I have same issue with 12629.


Edit Again:
This now works with then 12F629. No change to file or project. For some reason it worked the next day! Internal RC No Clock Out is configured just as it was yestarday. What gives?
 
Ive not got a new problem.
I cant seem to get GP1 to go high.
This makes my allready meagre looking, 5 led knight rider light look even crapper;)

Heres my code

Code:
;
;KNIGHT RIDER THINGY
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LIST P=PIC12F629
include "P12F629.inc"
    
    __CONFIG   _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT  

CBLOCK 0x20
SUBCOUNT
COUNT
LEDPORT

ENDC


PROGSTART
    
    ORG        0x0000
SETUP_OSC

    DELAYTIME     EQU D'100'    
    bsf STATUS, RP0 ;Bank 1
    call 3FFh ;Get the cal value
    movwf OSCCAL ;Calibrate
    bcf STATUS, RP0 ;Bank 0
SETUP
    BSF     STATUS,RP0    ;CHANGE TO BANK1
    MOVLW    0x00        ;SET W REGISTER 
    MOVWF    TRISIO        ;SET ALL PORTS TO OUTPUT
    BCF     STATUS,RP0    ;CHANGE TO BANK0
    CLRF     GPIO        ;CLEAR GPIO REG
    MOVLW    B'111'        ;DISABLE
    MOVWF   CMCON        ;COMPARATOR

START
    MOVLW    0x01        ;TURN first port
    MOVWF     LEDPORT        ;SET LEDPORT
    CALL     SYNCGPIO    ;MOVE LEDPORT INTO GPIO
    MOVLW    DELAYTIME    ;LOAD DELAY TIME INTO W
    CALL     DELAY        ;CALL THE DELAY ROUTINE
    GOTO    MOVELEFT    ;START MOVING BITS (LEDS) LEFT

SYNCGPIO
    MOVFW    LEDPORT        ;COPY LEDPORT BITS
    MOVWF    GPIO        ;INTO THE GPIO REGISTER
    RETURN

MOVELEFT
    RLF        LEDPORT, F    ;SHIFT BIT LEFT(I.E LED)
    ;CHECK IF NEXT PORT IS GP3
    BTFSC    LEDPORT, GP3;SKIP NEXT LINE IF ZERO
    RLF     LEDPORT,F    ;SKIP THIS PORT(GP3) SHIFT BIT LEFT(I.E LED)
    CALL     SYNCGPIO    ;MOVE LEDPORT INTO GPIO
    MOVLW    DELAYTIME    ;SET DELAY TIME
    CALL     DELAY
    BTFSC    LEDPORT, 5    ;CHECK IF WE ARE AT THE LEFTMOST POSITION    
    GOTO    MOVERIGHT    ;IF WE ARE AT LEFTMOST POS START MOVING RIGHT AGAIN 
    GOTO     MOVELEFT    ;MOVE LED LEFT AGAIN
    
MOVERIGHT
    RRF        LEDPORT, F    ;SHIFT BIT RIGHT(I.E LED)
        ;CHECK IF NEXT PORT IS GP3
    BTFSC    LEDPORT, GP3;SKIP NEXT LINE IF ZERO
    RRF     LEDPORT,F    ;SKIP THIS PORT(GP3) SHIFT BIT RIGHT(I.E LED)
    CALL     SYNCGPIO    ;MOVE LEDPORT INTO GPIO
    MOVLW    DELAYTIME    ;SET DELAY TIME
    CALL     DELAY
    BTFSC    LEDPORT,GP0    ;CHECK IF WE ARE AT RIGHTMOST POSITION.
    GOTO     START        ;GO BACK TO THE BEGINNING    
    GOTO     MOVERIGHT    ;MOVE LED RIGHT AGAIN
    

DELAY
        
    MOVWF    COUNT        ;LOAD VALUE # OF LOOPS FROM W REGISTER

DELAYLOOP        
    DECFSZ    SUBCOUNT
    GOTO DELAYLOOP
    DECFSZ    COUNT
    GOTO DELAYLOOP    
    RETURN




end
Any ideas?

many thanks:)
 
Last edited:
Your not clearing the carry flag before the first shift. Try,

Code:
MOVELEFT
    BCF        STATUS,C
    RLF        LEDPORT, F    ;SHIFT BIT LEFT(I.E LED)

And the same on MoveRight.

Mike.
 
Nice one mate, thanks once again.

Ive read the datasheet, but i dont really understand why this makes a difference. could you explain that to me please.
 
Pics are very difficult to blow. Are you using current limiting resistors? Is your supply less than 5.5V? Does your pic get hot? Can you post a schematic?

Mike.
 
Pommie said:
Pics are very difficult to blow. Are you using current limiting resistors? Is your supply less than 5.5V? Does your pic get hot? Can you post a schematic?

I agree, PIC's are VERY hard to damage, I've never managed it yet :D but I've got one that got so hot it's got my fingerprint burnt in the top! (don't put them in the socket the wrong way round!).
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top