PDA

View Full Version : Using PORTA as output



microcozmoz
- 8th January 2007, 10:51
Hi all,

I have a problem about using 16F628's PORTA as an output. I want to use only one bit for an output but I cant.
CODE :

Best Regards.

@ DEVICE pic16F628a
@ DEVICE pic16F628a, WDT_ON
@ DEVICE pic16F628a, PWRT_ON
@ DEVICE pic16F628a, PROTECT_OFF
@ DEVICE pic16F628a, MCLR_OFF
@ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT

TRISB = %00000000
TRISA = %11111110
PORTA = 0
PORTB = 0

OPTION_REG.7=1
CMCON=7

MAIN:
HIGH PORTA.5
PAUSE 1000
LOW PORTA.5
PAUSE 1000
GOTO MAIN

END

savnik
- 8th January 2007, 11:23
Hi all,

I have a problem about using 16F628's PORTA as an output. I want to use only one bit for an output but I cant.
CODE :

Best Regards.

@ DEVICE pic16F628a
@ DEVICE pic16F628a, WDT_ON
@ DEVICE pic16F628a, PWRT_ON
@ DEVICE pic16F628a, PROTECT_OFF
@ DEVICE pic16F628a, MCLR_OFF
@ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT

TRISB = %00000000
TRISA = %11111110
PORTA = 0
PORTB = 0

OPTION_REG.7=1
CMCON=7

MAIN:
HIGH PORTA.5
PAUSE 1000
LOW PORTA.5
PAUSE 1000
GOTO MAIN

END
You have only PORTA.0 as output in TRISA

microcozmoz
- 8th January 2007, 12:01
This code is only for example.Change High PORTA.5 to High PORTA.0 ...

Acetronics2
- 8th January 2007, 12:34
Hi, µcosmos

a look at the datasheet could show you the reason why ...

See table 3.2 " Pinout assignment " ... or table 5.1 !!!

Alain

microcozmoz
- 8th January 2007, 13:07
Thank you for your advice!! I must rtfds....

sayzer
- 8th January 2007, 13:13
When using HIGH or LOW commands, it does not matter whether the pin is registered to be as an input or output pin.

HIGH and/or LOW already set the pin as an output pin.

Just make sure that the pin is not an input only pin.


----------------------