Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 19th December 2003, 11:31 AM   (permalink)
Neiwiertz
Default porta 4 won't come high 16f876

I'm using a 16f876

pins a0 (input) a1 a2 a3 a5 will work but a4 not
i will to have that a4 is an output so i can drive a led on this pin

i'm using pic basic

DEFINE OSC 4 'CLOCK FREQUENTIE IS 4MHZ'

TRISC = %00000000
TRISA = %00000001
Adcon1 = %00000111
adcon0 = %00000000



TIJD var word

KNOPPEN var byte
XRICHTING var byte
YRICHTING var byte

MAIN:

'GOTO MEETTIJD
'IF (TIJD>2500)OR(TIJD<3500) THEN
'PORTA.5 = 0


'pause 1000

'ELSE
'PORTA.4 = 0
PORTA.1 = 1
PORTA.2 = 1
PORTA.3 = 1
PORTA.4 = 1
PORTA.5 = 1

'pause 1000
'ENDIF

GOTO MAIN


MEETTIJD:
pulsin PORTA.0, 1, TIJD

RETURN

ZENDNAARUSB:

PORTA.1 = 0
PORTA.2 = 0
PORTA.3 = 0
PORTC = 0

KNOPPEN = 32
XRICHTING = 128
YRICHTING = 255


PORTC = KNOPPEN
PORTA.1 = 1
PAUSE 100
PORTC = 0
PAUSE 100
PORTA.1 = 0

pauseus 1

PORTC = XRICHTING
PORTA.3 = 1
pauseus 1
PORTA.3 = 0

pauseus 1

PORTC = YRICHTING
PORTA.2 = 1
pauseus 1
PORTA.2 = 0

pauseus 1

RETURN


END
 
Reply With Quote
Old 19th December 2003, 12:18 PM   (permalink)
Default

A4 is often an open-collector output on PIC's, it can only sink current, not source it - add a pull-up resistor to make it work more like a normal output. As you are wanting to drive an LED, you could connect the LED and series resistor from the pin to +5V, the LED would then light when the pin is set low. Or, you could connect the LED from A4 to ground, with the series resistor from A4 to +5V - this would then light when the pin was high - but it does waste current when the LED is turned off as the resistor is then directly across the HT rail.
Nigel Goodwin is online now  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 01:34 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.