![]() |
Rookie Programmer has question about the default code
Hey guys, I'm taking a look at the code, and I've got a small question. On this part:
Code:
'========== MAIN PROGRAM ===================================================== |
I am not the programmer on my team and I have never worked with BASIC stamps, just with Atmel AVRs, which are programmed in assembler, but most microcontrollers have a similar syntax, so here is my explanation:
On microcontrollers, most of the ports (except, for example, for the analog ones) can be either input or output. To tell the controller how you would like to access the port, whether as input or output, you have to define it in teh initialization statements. This can obviously be done by writing 'Output' followed by the port number. From there on, you cann access it by the internal aliases out[port number]. Take this as a temporay help, I bet that someone who knows the BASIC Stamp really well is going to post a reply sometime later this day. Good luck! |
You should download the Parallax manual (V2.0 is worth getting if you have the older manual -- much clearer in my opinion).
Output is a Pbasic command that makes a pin an output on a Stamp2. What it REALLY does is set a bit in the DIRS word. There are 3 words that you should get to know if you are using Stamp2's a lot (not so much if you only use them for FIRST, but it is still good to know). DIRS is a word that sets the direction of data flow of the I/O pins 0-15 INS is a word that reflects the status of the voltage on the I/O pins 0-15. OUTS is a word that determines the output value of the I/O pins, if DIRS is set to the output state (which I can't recall whether it is a 1 or a 0 off the top of my head). Actually, the Stamp2 can only TRY to set the values to match OUTS, if something else is trying to make it something else, then it is a tug of war and the best man wins. With perhaps one of the battlers broken or wounded ;-) Anyway, Output X sets bit X of DIRS to output status. OUT1 is simply an alias for bit1 of OUTS. It is exactly the same as OUTS.bit1 Hope this helps. Joe J. |
Quote:
|
| All times are GMT -5. The time now is 01:30. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi