View previous topic :: View next topic |
Author |
Message |
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
18F2550 disable usb |
Posted: Sun May 17, 2015 7:43 am |
|
|
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
|
|
Posted: Sun May 17, 2015 7:54 am |
|
|
???
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
|
|
Posted: Sun May 17, 2015 8:12 am |
|
|
Yes, I mean the pin_c4.
How can I disable the USB module and the USB transceiver? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Sun May 17, 2015 8:27 am |
|
|
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
|
|
Posted: Sun May 17, 2015 8:40 am |
|
|
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
|
|
Posted: Sun May 17, 2015 10:19 am |
|
|
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
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sun May 17, 2015 9:14 pm |
|
|
Be thankful you are not trying to access non-USB I/O on C3,4,5
of the 16F745 |
|
|
Prefekt
Joined: 21 Oct 2010 Posts: 85
|
|
Posted: Mon May 18, 2015 3:28 am |
|
|
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);
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Mon May 18, 2015 7:58 am |
|
|
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.
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
|
|
Posted: Wed May 20, 2015 11:20 pm |
|
|
I have tested it yesterday ... it does not work.
I will build a simple circuit with a pic and test it again |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19549
|
|
Posted: Thu May 21, 2015 12:30 am |
|
|
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
|
|
Posted: Thu May 21, 2015 9:36 am |
|
|
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
|
|
Posted: Thu May 21, 2015 11:37 am |
|
|
It works
Thanks for the support! |
|
|
|