Jon Wilder
Active Member
WHOA WAIT A MINUTE!!!
First off...OUTPUTS cannot be externally controlled. Their output state is controlled INTERNALLY. However, pins that are set up as INPUTS are externally controlled. We READ inputs, but we WRITE to outputs.
No! Using a 1 ohm resistor between a PIC output pin and ground will overload the port pin and possibly either burn out the pin or the PIC itself! A straight wire from the pin to ground will do the same! When a pin is configured as an INPUT, you can ground it out all day long, but ground out a pin that is set up as an output and you're going to burn up the PIC. You only get 2 voltage values from a PIC OUTPUT...5V and 0V. PERIOD! End of story!
You are thinking completely backwards. The PIC can source 25mA @ 5V output. Using Ohm's Law, this means that the pin can safely drive loads down to 200R (5V / 25mA = 200R....simple Ohm's Law).
There is no "forcing output pins to a different output voltage". Output pins get toggled between the Vdd and Vss pins internally, which will only provide two possible output voltages...5V and 0V. Using anything lower than 200R on an OUTPUT pin will burn up the chip. If you're pulling the pin voltage down lower than 5V when setting the output pin high, this means that you are overloading the pin.
No...you're doing something completely wrong here.
If you want to be able to see if the pin is going to 1 or 0, put an LED in series with a 330R resistor between the pins and ground. They will give you a visual indication of what the pins are doing.
Can you explain in normal terms what you're trying to get the PIC to do? Cause from the sounds of it you're needing something with an on chip AD converter, which the F628A does not have.
Now since you wanted RA5 configured as digital input, I modified the config word in my last code posting. Please recopy, paste then assemble and the code should be correct. Wire up a couple of LED's with a 330R resistor in series with each LED, then place them on pins RA7 and RA0 and they should both come on.
First off...OUTPUTS cannot be externally controlled. Their output state is controlled INTERNALLY. However, pins that are set up as INPUTS are externally controlled. We READ inputs, but we WRITE to outputs.
PIC can provide max source of 25mA right? If I connect very small resistance (e.g. 1 Ohms), pic will have to change output voltage to 25mV in order to privide 25mA right?
No! Using a 1 ohm resistor between a PIC output pin and ground will overload the port pin and possibly either burn out the pin or the PIC itself! A straight wire from the pin to ground will do the same! When a pin is configured as an INPUT, you can ground it out all day long, but ground out a pin that is set up as an output and you're going to burn up the PIC. You only get 2 voltage values from a PIC OUTPUT...5V and 0V. PERIOD! End of story!
You are thinking completely backwards. The PIC can source 25mA @ 5V output. Using Ohm's Law, this means that the pin can safely drive loads down to 200R (5V / 25mA = 200R....simple Ohm's Law).
There is no "forcing output pins to a different output voltage". Output pins get toggled between the Vdd and Vss pins internally, which will only provide two possible output voltages...5V and 0V. Using anything lower than 200R on an OUTPUT pin will burn up the chip. If you're pulling the pin voltage down lower than 5V when setting the output pin high, this means that you are overloading the pin.
and when it happens and I read bit during it, will it read the latch value which I wroti in with bsf? as diagram shows form datasheet, it will read 25mV, which means 0 right? and if It's so, than everything works fine, I mean, that's normal action
No...you're doing something completely wrong here.
If you want to be able to see if the pin is going to 1 or 0, put an LED in series with a 330R resistor between the pins and ground. They will give you a visual indication of what the pins are doing.
Can you explain in normal terms what you're trying to get the PIC to do? Cause from the sounds of it you're needing something with an on chip AD converter, which the F628A does not have.
Now since you wanted RA5 configured as digital input, I modified the config word in my last code posting. Please recopy, paste then assemble and the code should be correct. Wire up a couple of LED's with a 330R resistor in series with each LED, then place them on pins RA7 and RA0 and they should both come on.
Code:
list p=16F628A, r=dec, w=1
include <P16F628A.INC>
__config b'10000100010000'
org 0x000 ;reset vector
goto START
START movlw 0x07 ;disable comparator
movwf CMCON
clrf PORTA ;init ports
clrf PORTB
banksel TRISA ;bank 1
clrf TRISA ;RA0-RA7 outputs
movlw b'00000001' ;RB1 input
movwf TRISB
banksel PORTA ;bank 0
bsf PORTA,7 ;RA7 high
btfsc PORTA,7 ;is RA7 low?
bsf PORTA,0 ;no, set RA0
goto $
end
Last edited: