PDA

View Full Version : I don't understand



Russ Kincaid
- 16th March 2007, 16:28
You folks have been very helpful as I am learning to program. My question is: what do I have to do to make porta.0 an input? My program, which does not work, is below:

REM DEVICE = 16F627A
REM DISABLE LOW VOLTAGE PROGRAMMING
REM CONFIGURATION: INTOSC CLOCKOUT, WDT DISABLED, PWR UP ENABLED,
REM MCLR enabled, BROWNOUT DISABLED, NO PROTECTION

REM PORT B ARE OUTPUT, PORTA NOT USED, EXCEPT FOR PORTA.0

TRISA = %10000000 'PORTA.0 IS STOP INPUT, ALL OTHERS OUTPUT
TRISB = %00000000 'ALL OUTPUTS

IF PORTA.0 = 0 THEN STOP
HIGH PORTB.0
HIGH PORTB.1
HIGH PORTB.2
HIGH PORTB.3
HIGH PORTB.4
HIGH PORTB.5
HIGH PORTB.6
HIGH PORTB.7

start:
low portb.0
pause 5000
high portb.0
goto start

END

When I apply power, porta.0 is low even tho there is a 10K pullup. All portb outputs are low. When reset is low, all portb outputs are high.

Russ

mister_e
- 16th March 2007, 16:30
your TRISA setting is backward.
TRISA= %00000001

and you have to disable the analog comparator
CMCON=7

Russ Kincaid
- 17th March 2007, 02:56
Thanks, I should have known it was backward, but I didn't know I had to disable the comparator.

Russ