Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F27J53 Disable USB

Status
Not open for further replies.

AtomSoft

Well-Known Member
Hey everyone, im trying to use RC4/5 as GPI (general purpose inputs) and can not seem to get them to read correctly...

My code for init is:
Code:
    ADCON0 = 0;
    ADCON1 = 0x0F;
    CM1CON = 0x00;
    ANCON0 = 0xFF;
    ANCON1 = 0x0F;
    CM2CON = 0x00;
    CCP1CON = 0;
    INTCON = INTCON2 = INTCON3 = 0;
    PIR1 = PIR2 = 0;
    PIE1 = PIE2 = 0;

    //DISABLE USB
    UCON = 0;
    UCFG = 0;

...

    if(PORTCbits.RC4 == 1)
        ToTerminal("CH0/RC4 is HIGH.\r\n\0");
    else
        ToTerminal("CH0/RC4 is LOW.\r\n\0");

Am i missing something? There is no TRIS for these pins as they are Input only... thoughts?
 
Did you see this
When used as general purpose inputs, both
RC4 and RC5 input buffers depend on the level of the
voltage applied to the VUSB pin, instead of VDD like all
other general purpose I/O pins. Therefore, if the RC4 or
RC5 general purpose input capability will be used, the
VUSB pin should not be left floating.
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. When configured for
USB operation, the data direction is determined by the
configuration and status of the USB module at a given
time. If an external transceiver is used, RC4 and RC5
always function as inputs from the transceiver. If the onchip
transceiver is used, the data direction is determined
by the operation being performed by the module at that
 
Yeah my PCB has VUSB to VDD..

Pins RC4 and RC5 are multiplexed with the USB module.
Depending on the configuration of the module, they can
serve as the differential data lines for the on-chip USB
transceiver, or the data inputs from an external USB
transceiver. When used as general purpose inputs, both
RC4 and RC5 input buffers depend on the level of the
voltage applied to the VUSB pin, instead of VDD like all
other general purpose I/O pins. Therefore, if the RC4 or
RC5 general purpose input capability will be used, the
VUSB pin should not be left floating.
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. When configured for
USB operation, the data direction is determined by the
configuration and status of the USB module at a given
time. If an external transceiver is used, RC4 and RC5
always function as inputs from the transceiver. If the onchip
transceiver is used, the data direction is determined
by the operation being performed by the module at that
time.
 
Also saw this:

Note: On a Power-on Reset, PORTC pins
(except RC2, RC4 and RC5) are configured
as digital inputs. RC2 will default as
an analog input (controlled by the
ANCON1 register). 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). The internal USB
transceiver has a POR value of enabled.

Which for some reason is exactly how i have it setup and not working :(
 
Yes, RC5 works now, but RC4 doesnt let me do anything :(..

Code:
 			case 0x31:
				OLD_TRIS = TRISC;
				TRISC |= 0b00010000;
				if(PORTCbits.RC4 == 1)
					ToTerminal("CH0/RC4 is HIGH.\r\n\0");
				else
					ToTerminal("CH0/RC4 is LOW.\r\n\0");
				done = 1;
				TRISC = OLD_TRIS;
				break;
			case 0x32:
				OLD_TRIS = TRISC;
				TRISC |= 0b00100000;
				if(PORTCbits.RC5 == 1)
					ToTerminal("CH1/RC5 is HIGH.\r\n\0");
				else
					ToTerminal("CH1/RC5 is LOW.\r\n\0");
				done = 1;
				TRISC = OLD_TRIS;
				break;
 
I hope its a (just this MCU) problem like perhaps a bad solder or something that burnt out that pin ? lol ill try another MCU and see.

Oh i forgot.. dont have anymore PCBs... ugh... i do have some on the way... about 2 weeks time tho. :(
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top