HI, KD60...
You say : I connect my switches to PortA ... and you define PortB as the inputs ... while you read Portb.
Where are your switches really connected ???
would a little look there help you ????
Alain
HI, KD60...
You say : I connect my switches to PortA ... and you define PortB as the inputs ... while you read Portb.
Where are your switches really connected ???
would a little look there help you ????
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
People... let's download and read the DATASHEET!
ADCON1 = 7
Last I looked the 16F628 didn't have A/D Converters and as such doesn't have ADCON Registers - but you might want to correct me on that...
CMCON=7 however is good because this PIC does have Comparators.
Connect your switches between the PICs pins and Vss. Connect pull-up Resistors between the PICs pins and Vdd. 10K is a good value. When the switch is OPEN, the PIC will see a 1 on that pin. When the Switch is Closed the PIC will see a zero.
If you use PortB, you won't need pull-up Resistors because you can enable the PICs weak pull-up's on that Port. Go look in the OPTION Register for Bit 7 to see how to do this.
>>You say : I connect my switches to PortA ... and you define PortB as the inputs ... while you read Portb.
I did have PORTA originally. I switched to PORTB for testing.
same results, no hi-low.
Also, forgive the syntax, was writing BC (before coffee)
Shawn
Here is the latest code bit:
define osc 4
CMCON = 7
TRISA = %11111111
TRISB = %00000000
PB0 VAR PORTB.0
PB1 VAR PORTB.1
PB2 VAR PORTB.2
PB3 VAR PORTB.3
SW0 VAR PORTA.0
SW1 VAR PORTA.1
SW2 VAR PORTA.2
SW3 VAR PORTA.3
SCAN:
If SW0 = 1 then
HIGH PB0:PAUSE 2000
ELSE
LOW PB0
ENDIF
If SW1 = 1 then
HIGH PB1:PAUSE 2000
ELSE
LOW PB1
ENDIF
If SW2 = 1 then
HIGH PB2:PAUSE 2000
ELSE
LOW PB2
ENDIF
If SW3 = 1 then
HIGH PB3:PAUSE 2000
ELSE
LOW PB3
ENDIF
HIGH PORTB.5
PAUSE 20
LOW PORTB.5
PAUSE 20
GOTO SCAN
I added the portb.5 so I could flash an LED to indicate the loop is running, which it does.
Still have no ouput on portb.0 to portb.3. The porta inputs are tied high with 10K resistors to +5v
Last edited by KD6OJI; - 10th December 2005 at 02:38.
Well, turns out the code was not the issue here.. Seems my WinPic tool I use to write to the chip could not find the device files from MPLAB. I reset the path, it found its device files, and now I have PORTA 0-3 working correctly as inputs.
Thanks to all for the help!
Bookmarks