PDA

View Full Version : How do I set GPIO 0-2 and 5 simultaneously?



cstack
- 19th August 2009, 02:42
My project is to control a stepper motor attached to a gunpowder trickler to trickle powder into a weighing scale pan. The only control would be an on/off switch and a pot. The PIC would use ADC to read the pot and control the trickle speed.
It works with 16F877 and 16f688 but I am stumped trying to move over to 12F683. I need to set 4 pins at a time for the stepper to turn, i.e.GPIO 0,1,2,5. GPIO.3 is only an input and I need a pin for ADC in (in this case GPIO.4)

Here is the problem:

FOR INDEX = 7 TO 0 Step -1
LOOKUP INDEX, [$1, $3, $2, $6, $4, $C, $8, $9], PATT
PORTC = PATT 'THIS WORKS FINE ON THE BIGGER PICS

(GPIO.0,GPIO.1,GPIO.2,GPIO.5 = PATT) ...this doesn"t work.

I am stumped. Charlie

Kamikaze47
- 19th August 2009, 07:32
GPIO=PATT should work. GPIO.0=PATT will not because it is referring to only one pin.

Kamikaze47
- 19th August 2009, 07:39
However, with those HEX numbers and GPIO=PATT it will use GPIO bits 0 1 2 and 3.

To use pins 0 1 2 and 5 you would need to change the loopkup to: [$1, $3, $2, $6, $4, $24, $20, $21]

I am also assuming that you are setting those pins as output pins.

sayzer
- 19th August 2009, 09:32
In addition to Kamikaze47's, there is another way of doing it; the traditional way.

Set them one by one.

like,

GPIO.0 = PATT.0
GPIO.1 = PATT.1
GPIO.2 = PATT.2
GPIO.5 = PATT.3

This will be so fast that your stepper can not react to the line changes.
Thus, Stepper will be running normally as if you were driving it at one shot.


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