Shop OBEX P1 Docs P2 Docs Learn Events
Command Order — Parallax Forums

Command Order

mynet43mynet43 Posts: 644
edited 2010-11-06 14:49 in Propeller 1
I have a question about the OUTA and DIRA commands.

The examples in the manual show the DIRA command before the OUTA command.

Some coding examples reverse the order. It seems to make sense to have the values set before you change the direction from input to output.

Would someone please explain what's going on here and why it matters?

Thank you for your help.

Jim

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-06 08:11
    The OUTA register is zeroed by default. If that makes sense for your application, it looks cleaner to set DIRA first, then set OUTA. If your application needs its outputs to be initially high, then you need to set OUTA first, then DIRA, so the outputs will be high once they're made outputs. This is particularly true for open-drain outputs where there's a pullup. There you want to make sure the outputs stay high until you're ready to pull them low and you want to initialize OUTA first.
  • mynet43mynet43 Posts: 644
    edited 2010-11-06 09:14
    Thanks Mike,

    That's what I needed to know, that the OUTA register is initialized to zero.

    It seems like it would always make more sense to set the OUTA value first, before the DIRA command.

    Otherwise, you would create a glitch when you set it to high. It would first go low when you set the direction to out, then back to high when you send the OUTA command.

    I think I'll keep doing it OUTA first, DIRA next.

    Thanks again,

    Jim
  • HarleyHarley Posts: 997
    edited 2010-11-06 14:49
    mynet43, Maybe this helps for the other order.

    I have a design which has some interfacing signals active low. Thus setting the Output register to a HI state, not active, then the DIRA direction, the output line only goes low when the program sets it that way. For instance, providing an Interrupt signal to say a micro, you'd have pull-up R on the line to make sure it is high on power-on time and ONLY low when the program outputs a low.

    Depends on the application. Sometimes it doesn't matter; others it is critical.
Sign In or Register to comment.