dira, and outa
blind_bot
Posts: 22
Hello, everyone.
·I recived my education propeller kit last week, and got it up and running fine. Today I started working threw lab 4. It explains how to use dira, and outa. Pretty easy stuff, still I have a question.
·In the text it shows how you can do the following:
········ dira[noparse][[/noparse]4] := 1, and the same goes for outa. It latter shows how you can use more than one pin in the same line by doing the following.
·········· dira[noparse][[/noparse]4..6] :=1, what I would like to know is if it is possible to do more than one pin in this way, say··· dira[noparse][[/noparse]4..6..8]?? When I tryed it I got a error, so I had to use only two pins in this way and then add a second line containg the dira command for the remaing pin.
·· I am very sorry to be asking for something so simple. Thank you very much, Duane
·······
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
00100000
·I recived my education propeller kit last week, and got it up and running fine. Today I started working threw lab 4. It explains how to use dira, and outa. Pretty easy stuff, still I have a question.
·In the text it shows how you can do the following:
········ dira[noparse][[/noparse]4] := 1, and the same goes for outa. It latter shows how you can use more than one pin in the same line by doing the following.
·········· dira[noparse][[/noparse]4..6] :=1, what I would like to know is if it is possible to do more than one pin in this way, say··· dira[noparse][[/noparse]4..6..8]?? When I tryed it I got a error, so I had to use only two pins in this way and then add a second line containg the dira command for the remaing pin.
·· I am very sorry to be asking for something so simple. Thank you very much, Duane
·······
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
00100000
Comments
you could do
dira := %10101000 ' make pins P4, P6, P8 outputs
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.mikronauts.com E-mail: mikronauts _at_ gmail _dot_ com 5.0" VGA LCD in stock!
Morpheus dual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory/IO kit $89.95, both kits $189.95 SerPlug $9.95
Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
Las - Large model assembler Largos - upcoming nano operating system
Writing OUTA[noparse][[/noparse] 1..2 ] := %01 sets bit 1 of OUTA to zero and bit 2 of OUTA to one. Writing OUTA[noparse][[/noparse] 2..1 ] := %01 sets bit 2 of OUTA to zero and bit 1 of OUTA to one.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
00100000
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
00100000
dira[noparse][[/noparse]4..8]:=%10101
outa[noparse][[/noparse]4..8]:=%10101
In the example above, pin 5 and 7 will be inputs.·If you want these to be·output low, use this instead
dira[noparse][[/noparse]4..8]:=%11111
outa[noparse][[/noparse]4..8]:=%10101
Post Edited (nohab) : 2/16/2010 9:51:31 AM GMT
So, yeah, having such a range that you mentioned should be no problem at all.· You can have any combination that you want.· I presume you can have multiple such statements scattered throughout your code (though I'm a newbie as well so another can set us straight).· With assembler, you'd need to configure/set the behavior of all 32 configuration bits/output pins at once (though still configuring first·and later setting at will as desired).· But SPIN lets you configure/set them individually or in groups, and break things up into multiple statements if desired, hiding the necessity of configuring/setting all 32 bits/pins at once.· So, firstly, make sure you are following up your dira direction configuration with an outa statement somewhere, as nohab said.· You probably learned that in the labs, but may have forgotten or neglected to do so along the way.· For simple applications, you'll likely just configure the pins once with dira (as you probably won't need to "turn the pin directions" around), but you'll probably need to execute outa statements multiple times, such as to blink·one or more·LEDs or to show the status of something (otherwise, you'd just plug in a light and call it a day and not need a microcontroller).·
So configure once with dira then set as many times as needed with outa.· Then, if you're still not seeing what you expect, you might want to check again to see if those results that you observed/reported are what you are "really" getting.· Also, perhaps other code is "overriding" your configurations or settings later on.· That is, perhaps other code subsequently has changed things, so check·all the code.· So, if you've configured the pins with dira AND you've used an outa statement...but things still don't seem to be working, then there's either something else at play or you're "wrong about being wrong" (something that often happens).· Remember to test that your tests are being conducted properly...or you'll think something isn't working when, in fact, it is working (or would be if not for something else getting in the way), or vice-versa.· You might even have pins cross- or mis-wired, such that what you think you're seeing is not really what's happening.· So, check your wiring.· Check everything!· Hopefully, you've just temporarily forgotten to use outa (after configuration with dira), but it could be something else.· Have confidence!· You're on the right track in continuing to experiment and to ask here.· Figure out the problem and get back to us with an update (for newbies like me), or let us know what you've tried and someone will point you in the right direction sooner or later (usually sooner than later, too).· Good luck.· Actually, "luck" is just a matter of continuing to try things.· Just be careful not to connect a high output to a low output...as that could/would blow your Propeller (something I expect I will do at some point), and that kind of luck you don't need.·