PDA

View Full Version : I'm fairly new at this and I Can Not Read PortA ... (using a 16F877 & PicBasic Pro)



Roddy Wayne
- 23rd October 2010, 17:23
Your help will be greatly appreciated!

My Code is below.


'************************************************* ***************
'* Name : No Smoke *
'* Author : Roddy Wayne *
'* Notice : *
'* : *
'* Date : 10/23/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************


CLEAR ;always start with clear
DEFINE OSC 4 ;define oscillator speed
define DEBUG_REG PORTC
DEFINE DEBUG_BIT 6
define DEBUG_BAUD 2400
DEFINE DEBUG_MODE 0
DEFINE DEBUG_PACING 1000
TRISA = %11111111 ;sets porta as inputs
TRISB = %11111111 ;sets portb pins as inputs
TRISC = %00000000 ;sets portc pins as outputs
TRISD = %00000000 ;sets portd pins as outputs
TRISE = %00000000 ;sets porte pins as outputs
B0 Var Byte
B2 Var Byte

Start:
B0 = PortB
'Peek PortB, B0 'Read PortB, put answer in B0
B2 = PortA
'Peek PortA, B2 'Read PortA, put answer in B2
Pause 25 'Short pause
Debug 14, 1, "B0 Byte = ", BIN8 B0, " ", 13'Display Byte B0, & next line
Debug "B2 Byte = ", Bin8 B2, " " 'Display Byte B2
Pause 1000 'Wait a second
Debug 1 'Send curser Home
If (B0 = %00000000) Then Start 'If no input, go to Start
If (B0 >=%00000001) Then LEDS 'If there's input, go to LEDS



LEDS:

High PortC.0 'Led On
Pause 500 'Wait .5 second
Low PortC.0 'Led Off
Pause 1000 'Wait a second
High PortC.7 'Beeper On
Pause 500 'Wait .5 second
Low PortC.7 'Beeper Off
Pause 58000 'Wait about 1 minute (total)

Goto Start
End

aratti
- 23rd October 2010, 19:46
By default portA is analog, to turn it into digital add: ADCON1 = 7 to your code before the tris setting.

Cheers

Al.

Roddy Wayne
- 23rd October 2010, 22:24
By default portA is analog, to turn it into digital add: ADCON1 = 7 to your code before the tris setting.

Cheers

Al.

Oops, I forgot about that!
Thanks Al! All works as it should now.