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 CCS Technical Support

18F2550 disable usb

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



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

18F2550 disable usb
PostPosted: Sun May 17, 2015 7:43 am     Reply with quote

Hello,

how is it possible to disable usb on 18f2550? I want use RC4 as data input pin.

Thanks
Volker
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun May 17, 2015 7:54 am     Reply with quote

Quote:

the RC


???

do you mean pin 14 - ie the absent pin_c3 ?? ak RC3 ?
if so easy to answer : NO it is a 3.3v regulator pin in purest hardware -not programmable in any way.

if you mean pin_c4 - YES it is useable as a simple TTL I/O pin
and the data sheet makes it clear HOW to do that

quoting:
Quote:
Note: 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


read section 10.3 of the datasheet
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sun May 17, 2015 8:12 am     Reply with quote

Yes, I mean the pin_c4.

How can I disable the USB module and the USB transceiver?
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Sun May 17, 2015 8:27 am     Reply with quote

They cannot be used as 'I/O', they can only be used as 'I'....

No output buffer, except the USB one. However is the USB is not turned on (it isn't by default), they will function as inputs. However not quite 'normal'. Unlike the other PortC pins, the input buffers are TTL, not Schmitt.

Quote from data sheet (where this sort of question should always start...).

"Unlike other PORTC pins, RC4 and RC5 do not have
TRISC bits associated with them. As digital ports, they
can only function as digital inputs."

The standard input functions will read them as normal.

The USB module is disabled when you wake the chip, unless you load USB code.
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Sun May 17, 2015 8:40 am     Reply with quote

I want it to use as an input pin.

But nothing changed on the pin if i switch from vss to vdd ...
pin_c4 is always 0!

???
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun May 17, 2015 10:19 am     Reply with quote

Quote:
But nothing changed on the pin if i switch from vss to vdd ...
pin_c4 is always 0!


perhaps this would be a good time to post your CODE ---
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 17, 2015 10:40 am     Reply with quote

Quote:
how is it possible to disable usb on 18f2550? I want use RC4 as data input pin.

http://www.ccsinfo.com/forum/viewtopic.php?t=34913
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun May 17, 2015 9:14 pm     Reply with quote

Be thankful you are not trying to access non-USB I/O on C3,4,5
of the 16F745 Smile Very Happy Sad Shocked
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Mon May 18, 2015 3:28 am     Reply with quote

Thanks for the answers.
I will try this at the evening ...


Code:
#include <18F4550.h>
#fuses XT, NOWDT, PUT, BROWNOUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#byte UCFG = 0xF6F
#bit UTRDIS = UCFG.3
//==========================
void main()
{
UTRDIS = 1;


while(1)
  {
   if(input(PIN_C4))
      putc('1');
   else
      putc('0');

   delay_ms(200);
  }
 
}


Smile
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Mon May 18, 2015 7:58 am     Reply with quote

Change the definitions to:

Code:

#bit UTRDIS = getenv("BIT:UTRDIS")


The compiler 'knows' where the transceiver disable is, and this avoids typing errors/chip changes causing problems. Smile

Personally I'd use:
Code:

#bit UTRDIS = getenv("BIT:UTRDIS") //USB transceiver disable

//==========================
void main()
{
   UTRDIS = TRUE; //disable transceiver


Which then 'comments' what this is doing.

The ability to do this by 'name', postdates PCM_programmer's original post.
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Wed May 20, 2015 11:20 pm     Reply with quote

I have tested it yesterday ... it does not work.
I will build a simple circuit with a pic and test it again Confused
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Thu May 21, 2015 12:30 am     Reply with quote

If you don't have a circuit, how did you 'test it'?.

You will see in the original thread, PCM_programmer pointed to, my 'warning' about simulators on this. Both MPLAB, and Proteus, do _not_ understand this ability, and won't read an input from the pin....
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Thu May 21, 2015 9:36 am     Reply with quote

I have the pic in a complete circuit and I make a new circuit only pic, crystal ... for testing!
Prefekt



Joined: 21 Oct 2010
Posts: 85

View user's profile Send private message

PostPosted: Thu May 21, 2015 11:37 am     Reply with quote

It works Very Happy

Thanks for the support!
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