PDA

View Full Version : 12F508 strange timing



pk7639
- 21st April 2007, 13:58
My circuit uses GP3 as an input (I modified 12F508.inc) and INTRC_OSC

The second block of this code (starting with the lable ccw:) loops at about 1/6th of the speed of the bit below the if statement???

Anyone seen anything like this?

Many thanks in advance

PK


OPTION_REG.5=0 'need to set this to use pin2 as an output
OPTION_REG.6=0 'this turns on the internal pull up resistors


stepDelay con 20 'delay in mS for each step

TRISIO=%01000 'set GPIO.3 as an input, all othe pins as outputs

loop: if GPIO.3=1 then ccw
GPIO=%00110
pause stepDelay
GPIO=%00101
pause stepDelay
GPIO=%10001
pause stepDelay
GPIO=%10010
pause stepDelay
goto loop

ccw: GPIO=%10010
pause stepDelay
GPIO=%10001
pause stepDelay
GPIO=%00101
pause stepDelay
GPIO=%00110
pause stepDelay
goto loop

skimask
- 21st April 2007, 16:19
OPTION_REG.6=0 'this turns on the internal pull up resistors

You know this doesn't affect all GPIO pins...right?

Acetronics2
- 21st April 2007, 17:02
My circuit uses GP3 as an input (I modified 12F508.inc) and INTRC_OSC

The second block of this code (starting with the lable ccw:) loops at about 1/6th of the speed of the bit below the if statement???

Anyone seen anything like this?

Many thanks in advance

PK


OPTION_REG.5=0 'need to set this to use pin2 as an output
OPTION_REG.6=0 'this turns on the internal pull up resistors


stepDelay con 20 'delay in mS for each step

TRISIO=%01000 'set GPIO.3 as an input, all othe pins as outputs

loop: if GPIO.3=1 then ccw
GPIO=%00110
pause stepDelay
GPIO=%00101
pause stepDelay
GPIO=%10001
pause stepDelay
GPIO=%10010
pause stepDelay
goto loop

ccw: GPIO=%10010
pause stepDelay
GPIO=%10001
pause stepDelay
GPIO=%00101
pause stepDelay
GPIO=%00110
pause stepDelay
goto loop


Hi,

May be I've missed something ...

but I see here you write the state of an input pin ... Try to write each pin one after each other instead of the whole port at once !!!

or better ... During the PAUSE, place the whole port as input, write your OUTPUT pins pattern ( 1 per 1 ), and AFTER, change for needed outputs with TRISIO ...

that is what we do for having directly output pins in a certain config, at power up ...

Alain



Alain

sayzer
- 21st April 2007, 22:49
GP3 is always an input pin no matter what you do.

Also, when you set a pin as an output pin, like you frequently do in your code, the weak pull-up register won't work the next time the same pin is set to be an input pin.

If you assign a pin as an input pin AFTER you set it to an output pin previously, then you need to register to weak pull-up register again.



----------------------------

Acetronics2
- 22nd April 2007, 09:49
Ah, ...

Last but not least ...

is MCLR configured as "internal MCLR" ... ???

didn't see anything about ...

Alain

PS: May be THIS .asm listing could help ... same function, but rotation selected by TWO pins ( stop allowed ...) !!!

pk7639
- 23rd April 2007, 00:25
[QUOTE=Acetronics;36807]Ah, ...

Last but not least ...

is MCLR configured as "internal MCLR" ... ???

Thanks for the reply Alain,
I modified the inc file and set MCLR_OFF.

I've since refined it, it has nothing to do with the blocks of code. Pulling GPIO low slows the chip down. It has this effect on the simplest of code (flashing led). Tonight I'll write something in C to see if it's a language thing.
The circuit is a friends, I'll draw a schematic from the board layout and see if he's done anything hinkey..

PK