Hello,
I have a problem. I'm using PIC16F627A and PicBasic-Compiler (NOT PRO!!).
If I use e.g. the commands 'PINx' , 'Button' or 'High/Low' they all work only on PortB. Is there a possibility that they work on PortA ??
Dirk
Hello,
I have a problem. I'm using PIC16F627A and PicBasic-Compiler (NOT PRO!!).
If I use e.g. the commands 'PINx' , 'Button' or 'High/Low' they all work only on PortB. Is there a possibility that they work on PortA ??
Dirk
Hi DiGG,
Did you remember to disable the analog and comparator features on PortA?
BobK
Hi DiGGi,
It usually depends on what's in the data sheet for the particular PIC you are using. These are something like: ADCON1 = 7 to disable the analog inputs and make the pins digital and CMCON = 7 to disable the comparators. There is a section in the PIC datasheet for each of these 2 items. Go to www.microchip.com and in the search field enter the part number you want a manual for. example: PIC16F628. This will give you selections on all the available documents for that part.
ADCON1 and CMCON are then placed in your initialization section of your program.
Please bear in mind that PICs that have analog ports don't necessarily have comparators. This is why you need to have the datasheet handy to refer to.
BobK
Hi,
fiorst ThX for your help, but in my data sheet there is no ADCON1 and CMCON.
is there an other solution , for PIC16F627A?
Diggi
No - As I remember, PBC does not have predefined pins or directions for PORTA. You must do them directly (make sure you turn off any analog presets as Bob has noted – this requirement is PIC specific).Originally Posted by DiGGi
For example to make RA0 high,
to turn off RA0 and turn on RA1, you could then do thisCode:poke $85, %00000000 ' make all PORTA outputs poke $05, %00000001 ' set RA0 high
Ask if you need more and good luckCode:poke $05, %00000010
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Ok i do a try, PicBasic is far different from PBP...
try
refer to figure 4-2 of the datasheet for the memory map, and section 10 for the comparator moduleCode:POKE $1F,7 ' disable comparator
About 'Pin' Statement... i guess it's valid but i can't confirm how and why... time for me to purchase PBC. I hate to guess..
Last edited by mister_e; - 10th September 2006 at 17:46.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
hi
Thank you both.
@paul borgmeier, yes i know but i want to read the pin states seperately
@mister_e the command you sent is working in PB but how can i controle the Pins on PortA with comands like Button/Pin ?
Dirk
Hi Steve,Originally Posted by mister_e
No need to buy PBC or guess - the manual is free online on MELABs site.
http://www.melabs.com/resources/index.htm#Manuals
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Not tried but should workOriginally Posted by DiGGi
Code:poke $85, $04 ' make RA2 an input ... peek $05, B0 ' read all of PORTA B0=B0 & $04 ' isolate bit 2 IF B0 = 0 then TurnOFF do something here if B0 = 1 goto IFEXIT TurnOFF: do something here if B0 = 0 IFEXIT: ...
Paul Borgmeier
Salt Lake City, UT
USA
__________________
hi
The text in '2.2. The Pins' chapter says that PIN, Button - Commands only work on PortB. That is annoying.
If I would use PEEK the stats of every pin would be written in a var.
E.G. Pin 4 and Pin 6 are high , tha var would look like %01010000.
Is that right?
Yes - BITWISE operate to find what you want. See the LET command for more in the PBC manual and my example above your last post.Originally Posted by DiGGi
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Thanks a lot @ all
I'll try this suggestion and i'll let you know the result.
Dirk
Edit: nevermind... too late![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi DiGGi,
What has been said to you in the last few replies has been correct. If you want to get real basic here you can read porta like this:
Peek PortA, B0 Read PortA and put results in Variable B0
If Bit0 = 1 then task 1 'Reads PortA pin 0, if 1 then goto task 1
If Bit1 = 1 then task 2 'Reads PortA pin 1, if 1 then goto task 2
If Bit2 = 0 then task 3 'Reads PortA pin 2, if 1 then goto task 3
This is really the basic way I started. You can do the BITWISE operations like Paul was showing you also. Whatever you are comfortable with.
Variable B0 now represents a reading of the pins on PortA. you can now look at each pin individually.
Do you have a copy of the PBC manual? If not goto www.melabs.com and download a copy. There is a 2 page explanation on PEEK and a small explanation of POKE.
BobK
thx
i read that manual allready. And found the Bitx command. But i haven't time to test it yet. I'll tiy it later. And let you know if it works or not.
Dirk
Bob,Originally Posted by BobK
Nice addition - your approach is certainly easier and faster to write. Utilizing the fact that Bit0, Bit1, etc. are predifeined as the bits of B0 is the better approach for straightforward (i.e., normal) operations. Thanks for adding - now Dirk has lots of options. If it were me, I would skip the bitwise stuff and use what Bob has above.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
hi,
my prog i working by using Peek and Bit0, Bit1 ...
Thanks for your help!
Diggi
Bookmarks