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

Port Configuration (Digital Inputs)

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



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

Port Configuration (Digital Inputs)
PostPosted: Thu Jul 26, 2012 8:16 am     Reply with quote

Hi there,

I am using a PIC18F4550.

I want configure pins RC4 and RC5 as digital inputs.
page 119 of the datasheet states
Quote:

On a Power-on Reset, these pins, except
RC4 and RC5, are configured as digital
inputs. To use pins RC4 and RC5 as
digital inputs, the USB module must be
disabled (UCON<3> = 0) and the on-chip
USB transceiver must be disabled
(UCFG<3> = 1).



So how do I configure the port for digital?

Thanks
Carl
TMLtech



Joined: 20 Jul 2011
Posts: 21
Location: Finland

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 11:26 am     Reply with quote

I use in that way:

#use fast_io(0b00110000);
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 12:58 pm     Reply with quote

Quote:
I use in that way:
#use fast_io(0b00110000);

This answer is incorrect. Please read the CCS manual and verify your
answer before posting.



To answer the question, the USB module is already disabled upon
power-on reset, so you don't need to do it. But the USB transceiver
is enabled by default, so you need to add a line of code at the start
of main() to disable it. See the program shown below:
Code:

#include <18F4550.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, NOLVP CPUDIV1
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#byte UCFG = getenv("SFR:UCFG")
#bit UTRDIS = UCFG.3

//=================================
void main()
{
int8 result;

UTRDIS = 1;    // Disable USB transceiver

while(1)
  {
   result = input(PIN_C4);
   printf("%u ", result);
   delay_ms(500);

  }


}
carl



Joined: 06 Feb 2008
Posts: 240
Location: Chester

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 1:19 pm     Reply with quote

Thanks PCM,

I will try it tomorrow.

Carl
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