S215 07 0614Revised 10-15-08
Ref. Sht. GH14-30 OEES 215
Custom
Functions
(Created for use
in OEES 215.)
XBasic & XCSB
OEES 215
| GetInBts( ) | Name:
Get input bits Inputs: none Returned: bits present on the PIC input pins |
When using XBasic, there are of course no actual PIC input pins. Instead, GetInBts( ) prompts the user to supply the inputs from the PC's keyboard. For both XBasic and XCSB, the input bits are returned by GetInBts. |
| SelBit(ibyt, bitno) | Name: Select
a bit Inputs: ibyt = input byte bitno = number of bit to be returned Returned: bit specified by bitno |
If bit bitno of ibyt is a 1, then binary 0000 0001
is returned. If bit bitno of ibyt is a 0, then binary 0000 0000
is returned. Notice that the bit requested is always shifted into bit
zero of the byte returned. Typically, GetInBts is first called to get the bits from the PIC's input pins, which are then put into a variable called ibyt. This variable (ibyt) is then sent to SelBit, along with the desired bit number (bitno). SelBit then returns the desired bit. It's good practice to handle inputs this way. If the program went back to the actual input lines each time it wanted to check a bit, things might have changed since it checked some other bit previously. With the technique described above, a snapshot (ibyt) is taken of the input lines. Individual bits in this snapshot are then analyzed by the program. Examples: - If ibyt is binary 0000 0111, and bitno is 2, then SelBit returns binary 0000 0001. Remember that the rightmost bit is bit 0. Thus, the three ones in ibyt are bits 2, 1, and 0. - If ibyt is binary 0000 0111, and bitno is 3, then SelBit returns binary 0000 0000. |
| Ob(bitvalue, bitno, now) | Name: Output a bit Inputs:
|
The eight PIC output lines are numbered 0 through 7, with
line 0 being the least significant bit. Ob only changes the value of the
output line specified by bitno.
All other lines remain unchanged. The variable now is needed mostly for use with XBasic in order to produce only one set of output bits on the PC's screen. When you are using XCSB, now also controls when the outputting actually occurs. In almost all cases, whether using XBasic or XCSB, set now to 1. Example: Assume the output lines initially have binary 1100 1010 on them. Also assume bitvalue is 1, bitno is 2, and now is 1. After Ob is called, the output lines will have binary 1100 1110 on them. Notice that output bit 2 has changed from 0 to 1, and that all other bits have remained unchanged. (Bit 2 is in boldface above.) |
| Init( ) | Name: Initialize Inputs: none Returned: nothing |
In XBasic, Init
simply displays a message about how to stop program execution. In XCSB, Init does the following: - Sets up all of the PIC's port A pins for inputting. - Sets up all of the PIC's port B pins for outputting. - Initializes variables used by functions such as Ob. |
| WaitForEnter( ) | Name: Wait for ENTER
to be pressed Inputs: none Returned: nothing |
Used only with XBasic programs. This function simply waits for the user to press ENTER on the PC's keyboard. |