Shop OBEX P1 Docs P2 Docs Learn Events
DIP Address Register RA Problem — Parallax Forums

DIP Address Register RA Problem

MacgruberMacgruber Posts: 20
edited 2010-10-27 19:10 in General Discussion
Hi,

I am trying to make an addressable circuit that uses all of the pins on the RA register. As I'm sure you all know, this register uses the four least significant bits since it only consists of four pins. The remaining 4 bits are "don't care" bits according to the SX datasheet. Unfortunately, when I make my address such that:

Addr PIN RA INPUT PULLUP

'

channelAdr = Addr

I don't seem to be getting the address value that I expect. I would debug but I am encountering an issue where the SX Key goes to sleep while stepping (maybe because of the 10kohm resistor across the reset switch). Anyway, the DIP switches just take the pins to ground so I would imagine that the address value would be 16 if none of the switches are thrown. This does not seem to be the case... Is it because of the "don't care" bits? Should I "AND" the Addr value with 00001111 to discard those bits? Ultimately, I want to shift the address << 4 so that the address is X16 thereby making each dip switch a larger address increment. If anyone could provide insight I would greatly appreciate it!

Thanks!

Comments

  • MacgruberMacgruber Posts: 20
    edited 2010-10-27 09:03
    Figured it out... Had to And out the bits I was not interested in and everything worked fine.
  • ZootZoot Posts: 2,227
    edited 2010-10-27 19:10
    Your solution is correct. The higher four bits of RA are not "don't care" but rather, are "unused". In fact, if you are ever really tight for "global" variable space, you can use these upper four bits (if they are set to output) for bit flags and the like.

    You could also avoid needing to mask them for your addressing scheme by doing something like this:
    addr PIN RA INPUT PULLUP
    UNA4 PIN RA.4 OUTPUT
    UNA5 PIN RA.5 OUTPUT
    UNA6 PIN RA.6 OUTPUT
    UNA7 PIN RA.7 OUTPUT
    ' then just make sure to init the upper pins
    W = RA
    W = W & $0F
    RA = W
    ' do the above just in your init/start section
    'then the upper four bits of RA will be zeros forever
    
Sign In or Register to comment.