Shop OBEX P1 Docs P2 Docs Learn Events
Group I/O - Propeller C Learning System — Parallax Forums

Group I/O - Propeller C Learning System

KC9RXBKC9RXB Posts: 15
edited 2014-08-26 08:23 in Learn with BlocklyProp
Hello everyone!

Radio shack put had a huge sale so I went on a little bit of a 'binge' and bought up all sorts of sensors and electronics in the region. Among those electronics was a Propeller quickstart board. I started going through the C tutorials (very good job as always, Parallax) and got to the part about controlling a 7-segment LED using the "set_directions" function.

I was wondering if there is a way to group several I/O pins that are not in order. For example I have 16 pins (1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31) but would still to be able to do something like this "set_outputs(15, 8, 0b11100111);"

Thank you,
Miles.K KC9RXB

Comments

  • jazzedjazzed Posts: 11,803
    edited 2014-08-25 22:52
    Hi there.

    You could always use DIRA and OUTA statements. For example ...
    #include <propeller.h>
    
    int main()
    {
      DIRA  = 0b1111; // set P0..3 pins to output and all other pins inputs
      DIRA |= 0b1111; // set P0..3 pins to output preserving state of other pins
      OUTA |= 0b0101; // set P0 and P2 high preserving state of other pins
    }
    
  • KC9RXBKC9RXB Posts: 15
    edited 2014-08-25 22:58
    Unfortunately that wouldn't work for me because the pins are not contiguous
  • jazzedjazzed Posts: 11,803
    edited 2014-08-25 23:16
    KC9RXB wrote: »
    Unfortunately that wouldn't work for me because the pins are not contiguous


    But how would you do it otherwise?

    The only way to set pin output states is by using DIRA and OUTA or through some counter output mode like video.
  • kwinnkwinn Posts: 8,697
    edited 2014-08-26 07:43
    Having non-contiguous pins will also make controlling the segments more difficult. You will need a word or long lookup table to do this.
  • jazzedjazzed Posts: 11,803
    edited 2014-08-26 08:23

    If you need a function to do set_outputs(15, 8, 0b11100111); on all odd pins, it is achievable. It won't be very fast though because a short algorithm would be used to set the appropriate bits based on the mapping. That is left to an exercise for the curious reader.
Sign In or Register to comment.