Page 1 of 1
18f4550 usb issues
Posted: Thu Oct 25, 2018 11:49 am
by Roy Johnston
I need to use ports C4 and C5 in the PIC18f4550. However, the datasheet says:
"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)."
can someone help me with the config setting in flowcode please.
Re: 18f4550 usb issues
Posted: Thu Oct 25, 2018 1:35 pm
by Steve
I think this should work...
At the start of your program, add a C-icon and enter the following:
Re: 18f4550 usb issues
Posted: Thu Oct 25, 2018 2:29 pm
by Roy Johnston
Thank you,
unfortunately it is not helping.
I attached my flowcode.
I simply cannot read the two inputs as inputs.
is it not possibly the standard config in Flowcode overriding this instruction.
Re: 18f4550 usb issues
Posted: Thu Oct 25, 2018 2:49 pm
by Roy Johnston
I have basicly done a simple flowcode only to test this function, it is not working.
Re: 18f4550 usb issues
Posted: Thu Oct 25, 2018 5:06 pm
by Steve
There seem to be lots of issues with these pins on that chip. Another suggestion from my searches is to add these to the C-icon:
Code: Select all
ADCON1 = 0x0F;
CMCON = CMCON | 0x07;
Unfortunately, I don't have suitable hardware to hand so I can't test.
Re: 18f4550 usb issues
Posted: Fri Oct 26, 2018 7:40 am
by Roy Johnston
Thank you for trying,
unfortunately it did not help.
Re: 18f4550 usb issues
Posted: Fri Oct 26, 2018 11:31 am
by Benj
Hello,
This is the code we use on the 18F4550 devices to initialise them with all I/O.
Code: Select all
ADCON0 = 0x3D;
ADCON1 = 0x0F;
UCFG = 0x08;
cr_bit(PIE2, USBIE);
Hopefully this will work for you.
The pins C4 and C5 should hopefully now work as inputs, the pins cannot be used as outputs.
Re: 18f4550 usb issues
Posted: Sat Oct 27, 2018 7:57 am
by Roy Johnston
thanks for the help but Unfortunately it has not helped.
.
I have written a basic program, that reads 3 inputs and switches 3 outputs.
input D4 works perfectly
C4 and C5 don't , the following happens.
if C4 is high or low the output is low.
if C5 is high or low the output is low.
if C$ and C5 is high then both outputs are high, however it remains high irrespective of the inputs.
[attachment=0]usb_input.fcfx
Re: 18f4550 usb issues
Posted: Sat Oct 27, 2018 7:59 am
by Roy Johnston
thanks for the help but Unfortunately it has not helped.[attachment=0].
I have written a basic program, that reads 3 inputs and switches 3 outputs.
input D4 works perfectly
C4 and C5 don't , the following happens.
if C4 is high or low the output is low.
if C5 is high or low the output is low.
if C$ and C5 is high then both outputs are high, however it remains high irrespective of the inputs.
Re: 18f4550 usb issues
Posted: Sun Oct 28, 2018 10:44 am
by Roy Johnston
Thank you for all the help.
I came right.
it ended up being the chip not functioning the way it should have.
I replaced the 18F4550 and all is well now.
all we need to do is disable the usb voltage regulator (bit 21) in the config parameters and it works like a charm.