Re: PIC BASIC command query
Poriet,
So which PIC are you using? Is it the 18F25K20 that is on the(my) Amicus?
Which ever one you are using... (and whenever you use a new PIC) ALWAYS download the .pdf datasheet for that PIC (google the PIC partnumber and "datasheet"). Then spend some time looking through it... Look for the section that summarizes the various "Registers" in the PIC... this section is KEY to setting up the PIC pins to be what ever you want them to be. (input, output, analog, pulse width modulation, etc)
Understanding how to reference the datasheet as you set up your PIC is probably one of the hardest(for me) and yet one of the most critical and necessary steps. The "TRIS" register is where you set a pin to be 1=input or 0=output.
Take a look at some of the example programs in the "wiki" section of this fourm and pay attention to the comments in the various programs and you will be able to learn how others set up the PICs to function as they need them to.
I seem to remember that "DIRS" could be a throwback to the BASIC STAMP as the PIC Basic language is quite similar and an attempt was made to have PBP be compatible to the basic stamp.
From an older version of the PBP manual...
The BASIC Stamp variable names Dirs, Dirh, Dirl and Dir0-Dir15
are not defined and must not be used with the PICBASIC PRO Compiler.
TRIS must be used instead, but has the
opposite state of Dirs.
This does not work in PICBASIC PRO:
Dir0 = 1 ‘ Doesn’t set pin PORTB.0 to output
Do this instead:
TRISB.0 = 0 ‘ Set pin PORTB.0 to output
Hope this helps...
Don't give up once you get over the initial hurdle of setting up your PIC and learning how the set the registers it is very rewarding.
Keep asking questions if you need more guidance...
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Bookmarks