View previous topic :: View next topic |
Author |
Message |
Alzmeier
Joined: 06 Feb 2014 Posts: 3
|
PIC 18F4550 RC4 RC5 Digital input Problem |
Posted: Thu Feb 06, 2014 8:35 am |
|
|
Hello all,
I want to use the RC4 and RC5 Ports as digital inputs.
So I added:
Code: |
// disable USB module
#byte UCON = 0xF6D
#bit USBEN = UCON.3
// disable on-chip USB transceiver
#byte UCFG = 0xF6F
#bit USBTRANS = UCFG.3
void main()
{
// ...
USBEN = 0;
USBTRANS = 1;
do
......
|
They are working, but sometimes without a external Signal Voltage they turn to 1. I use 10kohm external Resistence for pull down and 100 ohms in the signal Line.
To check them I use
Code: | RC5=input_state(PIN_C5); | If somebody has an idea, would be great, because I´m getting mad.
Thanks |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Feb 06, 2014 8:42 am |
|
|
is there any issue with using input_state() for the pins in question??
or does that fail for you too??
what drives the pins externally?
perhaps your "disable" strategy is not working as you believe??
what compiler version?? |
|
|
Alzmeier
Joined: 06 Feb 2014 Posts: 3
|
|
Posted: Thu Feb 06, 2014 8:54 am |
|
|
externally it is a signal 5V, 100Ohm in Serial, 10kOhm for pull down, the 5V are connected when a Relay is closed,
I use input_state, because at all my other inputs it is working fine |
|
|
Alzmeier
Joined: 06 Feb 2014 Posts: 3
|
|
Posted: Thu Feb 06, 2014 9:08 am |
|
|
Sorry,
compiler version PCWH 3.245
the problem is that they work, I connect 5V, I get a 1, I disconnect 5V, I get a 0. But some times they get to 1 without an external 5V |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Feb 06, 2014 9:10 am |
|
|
Jast had a look at the datasheet, page 119,chapter 10.3. There's an entire PAGE on how complicated the 'setup' is for those 2 pins!
Yeesh...My guess is your code edits the tris registers which can be a big problem. You might have to use fast_io() and manually configure the ports.
hth
jay |
|
|
|