Shop OBEX P1 Docs P2 Docs Learn Events
PLP_C question — Parallax Forums

PLP_C question

T ChapT Chap Posts: 4,223
edited 2006-09-25 11:30 in General Discussion
Can I use PLP_C to hold an input high when floating until GND is present on a switch?

I want to use a 4 spst dip switch to set an address, but don't have room to add pullup resistors and was hoping this would do the job.


TRIS_C = %11110000 'RC.0, 1, 2 ,3 to inputs
PLP_C = %00001111 'hold inputs RC.0 - RC.3 high, but can be forced low with switch

Comments

  • BeanBean Posts: 8,129
    edited 2006-09-25 02:58
    TRIS_C = %11110000 will make RC.7,6,5,4 inputs and RC.3,2,1,0 outputs
    PLP_C = %00001111 will hold RC.7,6,5,4 high

    Aside from having the wrong bits shown, the code WILL do what you want.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
  • T ChapT Chap Posts: 4,223
    edited 2006-09-25 03:48
    Great thanks Bean for the correction. I am really liking these SX chips.

    Here is the plan:

    4 pin dip switch on both Tx and Rx side. In cases where user has more than one system, they can put each system on it's own "channel" by setting the dip switches to the same settings. 16 options for channels.

    On boot up, a VAR named ChanId loads in i/o bank C somehow. ChanId = RC? dips are connected to RC.0 - RC.3 ( trying to arrive at 11110000 if 0-3 are high.)

    If all 4 switches are in "high" position, the byte is recorded into ChanId as %11110000

    Then, serByte gets the bytes as the come in, which will be either %00000001 or %00000011 + whatever the Tx ChanId is set to.


    serByte = RecByte 'goes sub and gets byte
    FinalByte = serByte - ChanId 'Deducts its ID back out
    If FinalByte = %00000001 Then
    'move motor up
    IF FinalByte = %00000011 Then
    'move motor down

    Is this a decent idea?
  • BeanBean Posts: 8,129
    edited 2006-09-25 11:30
    originator99 said...
    ·( trying to arrive at 11110000 if 0-3 are high.)
    You need to realize that bit numbering goes from right to left. In other words:

    %11110000 <- Value
    · ·76543210 <- Bit number

    So 11110000 has 0-3 low, and 4-7 high.

    Other than that, your method should work.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    There are only two guaranteed ways to become weathy.
    Spend less than you make.
    Make more than you spend.
    ·
Sign In or Register to comment.