How to send 7 cases and read 7 cases
Nauketec
Posts: 51
Howdy,
I have a project that uses 2 BS2P40 micros.
I need to send 0 to 7 cases out from one micro to be read by the other.
Unfortunately,· The pins chosen are off by a bit (no pun).·
The first micro uses ports (not pins) P1, P2, P3 to send data out, (there is nothing on PO, it was a mistake).
The·second micro uses ports (not pins) P0, P1, P2 to read data in. (P3 is used as an output)
I think what I need to use is the INA and OUTA commands but not sure how to filter out the unsed ports.
I would really appreciate any help but please use comments for I am a newbie.
Thanks
Daniel
I have a project that uses 2 BS2P40 micros.
I need to send 0 to 7 cases out from one micro to be read by the other.
Unfortunately,· The pins chosen are off by a bit (no pun).·
The first micro uses ports (not pins) P1, P2, P3 to send data out, (there is nothing on PO, it was a mistake).
The·second micro uses ports (not pins) P0, P1, P2 to read data in. (P3 is used as an output)
I think what I need to use is the INA and OUTA commands but not sure how to filter out the unsed ports.
I would really appreciate any help but please use comments for I am a newbie.
Thanks
Daniel
Comments
DIRA
INA
OUTA
Are your friends here. Each of the above represents some aspect of pins 0-3 (let's presume for discussion that you have the correct IO bank on the BS2p set.
BTW -- If you need to comm. between to BS2p40s, personally I would use two pins on each and a high-baud SERIN/SEROUT with flow control (then you are much more flexible).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 8/21/2008 10:56:54 PM GMT
You can use INA and OUTA to affect those lines. When reading INA the trick to ignoring the value of one of the bits depends on how you want to handle things. If your case since they literally are off by one bit you can simply shift the nibble left/right as necessary to properly align it with the next stage. On the end stage to ignore the bit you don’t want you simply mask it using bitwise AND. So you could do:
Result = INA & %1110 this will mask bit 0 from the variable.
Result = INA & %0111 this will mask bit 3 from the variable
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
The first micro was to send out through ports P1 P2 P3 should I just change the INA comand for OUTA?
and change the DIRA to %1110 ?
I am waiting to see if I become your post # 1000
thanks
Danel
if this variable named Result masks the bits - is that result in bin also or DEC and do I need to leave out numbers - example:
would the results be 0000 = DEC 0
the next would be 0001 = can not be used
the next usable be 0010 = DEC 2
is that the correct truth table?
Result = INA & %1110 this will mask bit 0 from the variable.
Result = INA & %0111 this will mask bit 3 from the variable
thanks Daniel
You would modify both DIRA and OUTA to "send" info -- DIRA will let you switch those pins to outputs, OUTA will let you set those now outpin pins to 1s (high) or 0s (low).
Certainly make sure to connect the pins of the two Stamps together through a resistor (so if both pins on either end are *accidentally* made outputs and one is high and one is low you don't get a short. Or you could pull up all 3 lines with a 10k resistor, and just drive them low, i.e.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 8/23/2008 8:29:32 AM GMT
Here is the code I am working with if you choose to look at it or have a go at changing it for me to test.
Thanks for all the help
Daniel
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering
eg:
LED_out VAR Nib
LED_out=5· 'LED_out value now looks like this binary value %0101.......(P0=1,P1=0,P2=1 and P3=0)
LED_out=LED_out << 1·· ''LED_out value now looks like this binary value %1010.......(P0=0,P1=1,P2=0 and P3=1)
OUTA=LED_out 'Your output pins (P1 to P3) now contain the value 5
Those 3 outputs will be read by the the other processor on P0 to P2
eg:
CheckMode:
LED_in VAR Nib
LED_in =INA & 7· 'We don't need P3 so we use the mask
ON LED_in GOSUB mode7,mode6,mode5,mode4,mode3,mode2,mode1,mode0 'if LED_in=5 gosub mode2 etc
mode1 mode2 etc are sub routines so at the end of each routine replace GOTO main with RETURN
Jeff T.
So much touble about these three pins I am electing to move the traces.· I hate putting in wires toa board but I left provisions with extra holes at each IO pin just in case.· So I am moving them now.
If you could help me with the new code that would be great so I can put this issue to rest· I need to send out P0 P1 and P2 on one chip and make a debug so I can see the data and recieve data on the second micro om P0 P1 P2. and make a debug window to see it.· You are using Gosub my program is uses goto comands on one side I need pieces that go into the sections that state something like outa =·0, 1,2,3 4,.... 7 and on the otherside· reads 0 - 7 and sends it to a goto mode1,mode2,mode3 ... mode7
Thanks again.