PDA

View Full Version : Help/Explanation needed



SahdowSA
- 17th February 2010, 07:40
Hi all. I'm new to this forum and to PicBasicPro and need some help.

This is my code:
TRISA = 0
Main:
Pause 250
High PortA.0
Pause 250
High PortA.1
Pause 250
Low PortA.0
Puase 250
Low PortA.1
Goto Main
End

(Tried this as well: Symbol LED = PORTA.0, High LED AND PORTA.0 = 1)

My expectation is that PORTA.0 will go high, then PORTA.1 will go high while keeping pin 0 high. But this is not the case. When I make any pin high, the rest go low. Is this the correct bahaviour?

I underdstand PortA = 7 will cause pins 000111 to go high, but surely portA.x should not affect the state of the other pins? or am I wrong?

I'm using a PIC16F676 with PicKit 2 Programmer.

Thanks in advance

mackrackit
- 17th February 2010, 07:54
Welcome to the forum.

The PIC you are using has analog on PORTA. You will need to make it digital.
Add this near the top of your code


ANSEL=%00000000
CMCON=%00000111

And this thread will be some good reading
http://www.picbasic.co.uk/forum/showthread.php?t=561

SahdowSA
- 17th February 2010, 08:23
Thanks a million. it worked!