Shop OBEX P1 Docs P2 Docs Learn Events
Question about how to use INA and OUTA — Parallax Forums

Question about how to use INA and OUTA

KraZe_EyEKraZe_EyE Posts: 15
edited 2008-11-12 22:37 in BASIC Stamp
I understand that INA is a nibble that represents the current state of pins 0 - 3, and that OUTA will output on pins 0 - 3.

Can i use OUTA like this OUTA = 6 Store that in an outside memory chip
Then read it back from the memory test var = INA And get my 6 back as a binary 0110?

Do i have to put a binary number in OUTA? ie. OUTA = 0110

Basically for my final project I am trying to read data from an arithmatic logic unit(ALU) write it to memory, then read it later.
The address location and the read/write functionality is controlled by the stamp.

Here's the memory chip www.datasheet4u.com/share_search.php?sWord=TMS2114

And below is my program

Thanks for your help!

Post Edited (KraZe_EyE) : 11/12/2008 3:25:59 AM GMT

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-12 03:30
    The hardware does not care how you represent the number -- binary, octal, hexadecimal, decimal, or other. It's still the same number. The compiler cares, but no matter whether you say 6, $6,%0110, or something else, the number is the same. It's like asking, will water still help my plants grow if instead of calling it "water", I instead say "Wasser" (German), "agua" (Spanish), or "eau" (French). The plants won't care what language you use, and neither will the electronic hardware.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-12 04:01
    Just putting a value in OUTA will not write it to the memory. You have to activate the appropriate control lines (Chip Select and Write Enable). Similarly, you have to control the memory to read the data from a particular address, then you can use INA to sense the signal on the 4 data lines. You also have to use DIRA to select the direction (input or output) and do it so that the memory doesn't try to output data at the same time that the Stamp I/O pins are in output mode.
  • KraZe_EyEKraZe_EyE Posts: 15
    edited 2008-11-12 15:48
    So I can write a number using OUTA=6, and it will make the pins 0110. Using INA I can also store by using the command testvar=INA, correct?

    I'm not sure what DIRA does; can I have a little example?


    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-12 15:53
    Read the PBasic manual, particularly the section on Stamp architecture and memory organization. The direction register sets the direction of the I/O pins (input or output) and has the same divisions into bit groups as the input or output register.
  • KraZe_EyEKraZe_EyE Posts: 15
    edited 2008-11-12 21:45
    Okay I get the use of DIRs; but is this set in stone for the program? If i set an IO pin to an input can I change it later to and output?
  • Lab RatLab Rat Posts: 289
    edited 2008-11-12 22:05
    if the coding says input at a set time it is an input if later in the the program you say output on the pin i would imagine that it will then become an output
    but i cant be 100% SURE only 99%
    computers do this with a speacial chip but i forget what it was
    it just lets datat from in one direction or the other via an internal switch
    i have a few but i dont know where they are to get you the numbers

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Parallax posesses power beyond belief.

    Believe in it.

    Post Edited (Lab Rat) : 11/12/2008 10:12:13 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-12 22:17
    You can change an I/O pin at any time from input to output or from output to input by changing the contents of the corresponding DIR register bit.
  • KraZe_EyEKraZe_EyE Posts: 15
    edited 2008-11-12 22:37
    alright my project is working!!!!!!!!!!!!!!!!!!!!

    thanks alot Mr. Green

    I hope you guys can answer my n00b question cause this is the only thing holding project up.
    I want to continously scan INA and display the result in a DEBUG statement, problem is I have the exit loop waiting for 'answer' to NOT = 0.
    This screws it up because the stamp waits for me to input the 'answer' and therefore never refreshes the debug statement.

    Any ideas? if this doesn;t make sense tell me and i'll try again


    ReadWrite:

    s1=1
    s2=1
    alu=0
    PAUSE 10
    DO
    answer = 0
    DEBUG CR,"Current ALU output is ", BIN5 INA, ", would you like to write ALU data to memory?",CR
    DEBUG "0 for NO, 1 for YES",CR
    DEBUGIN BIN1 answer
    LOOP WHILE answer = 0

    alu=1

    IF answer = 1 THEN
    GOTO careful
    ELSE
    GOTO main
    ENDIF
    RETURN
Sign In or Register to comment.