18f4550 usb issues

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

18f4550 usb issues

Post 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.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: 18f4550 usb issues

Post by Steve »

I think this should work...

At the start of your program, add a C-icon and enter the following:

Code: Select all

UCON = 0x00;
UCFG = 0x08;

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post 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.
Attachments
controller_3_Tester.fcfx
(50.27 KiB) Downloaded 216 times

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post by Roy Johnston »

I have basicly done a simple flowcode only to test this function, it is not working.
usb_input.fcfx
(17.87 KiB) Downloaded 308 times

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: 18f4550 usb issues

Post 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.

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post by Roy Johnston »

Thank you for trying,
unfortunately it did not help.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 18f4550 usb issues

Post 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.

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post 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
Attachments
usb_input.fcfx
(9.55 KiB) Downloaded 222 times

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post 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.
Attachments
usb_input.fcfx
(9.55 KiB) Downloaded 226 times

Roy Johnston
Flowcode V4 User
Posts: 220
Joined: Mon Aug 24, 2009 8:38 am
Has thanked: 2 times
Been thanked: 34 times

Re: 18f4550 usb issues

Post 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.

Post Reply