CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC 18F4550 RC4 RC5 Digital input Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Alzmeier



Joined: 06 Feb 2014
Posts: 3

View user's profile Send private message

PIC 18F4550 RC4 RC5 Digital input Problem
PostPosted: Thu Feb 06, 2014 8:35 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Feb 06, 2014 8:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 8:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 9:08 am     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 06, 2014 9:10 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group