How do I set GPIO 0-2 and 5 simultaneously?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Default How do I set GPIO 0-2 and 5 simultaneously?

    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

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    GPIO=PATT should work. GPIO.0=PATT will not because it is referring to only one pin.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    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.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    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.


    ---------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. Interruptus Frustratus
    By Byte_Butcher in forum General
    Replies: 16
    Last Post: - 17th April 2009, 20:36
  3. 16F628A - Stops if release power switch.
    By dene12 in forum General
    Replies: 16
    Last Post: - 14th February 2009, 07:57
  4. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts