USB serial(PIC18LF14K50) not working.

Any bugs you encounter with Flowcode should be discussed here.
electronick
Posts: 13
http://meble-kuchenne.info.pl
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Flowcode v10 USB serial(PIC18LF14K50) not working.

Post by electronick »

Hello everybody.

I have just(today) upgraded from FC7 to FC10 and have just now experienced the very same bug?
in FC10 as in FC7.
I start by setting up a project using:
PIC18LF14K50 @48Mhx using 12MHz crystal.

I have been trying to use this PIC as a USB serial device but it just won´t budge.
Nothing happens at all if it´s connected to a PC, 1sec blink works perfectly.
What´s even more strange is, if I delete the USB serial component, and and insert an, for example, USB slave component, I get a compilation error:

:0:: error: (499) undefined symbol:
_USBDeviceTasks(Loopslave_USB_2.0_18lf14k50.o)
(908) exit status = 1
Error returned from [xc8.exe]
C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\PIC\batch\pic_xc8_comp.bat reported error code 0x1
Autoclose turned off
FINISHED

This message will appear regardless of which USB component I insert?!
I attached the file which won´t compile for me after deleting then reinserting the USB serial component.
What is even more strange is that I get the same behavoiur from FC7?!
I have repeatedly tried to reboot my PC(Windows 10, 64bits) but it has no effect.

Please advice.

Nick
Attachments
Loopslave_USB_slask_18lf14k50.fcfx
(6.33 KiB) Downloaded 125 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: USB serial(PIC18LF14K50) not working.

Post by BenR »

Hi Nick,

Do you want to try this and see how you get on.
Loopslave_USB_slask_18lf14k50.fcfx
(9.04 KiB) Downloaded 115 times
The USB serial component was failing to add for me so I've re-exported it and pushed the latest to the Help -> Library updates.

The USB slave component requires you populate the Slave Macro property with a valid name of one of your Flowcode macros. Here I've created a macro called Service.
Capture.PNG
Capture.PNG (62.21 KiB) Viewed 1094 times

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: USB serial(PIC18LF14K50) not working.

Post by electronick »

Hi Ben.

Thank´s a lot :-)

I will try the file you uploaded and give it a try.

regards
Nick

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: USB serial(PIC18LF14K50) not working.

Post by electronick »

Hi all.

An update in this matter.
Still no luck using either:
PIC18LF14K50
Or
PIC18F14K50, as a USB serial, My PC doesn´t even detect it when either one is plugged in.
For testing purposes, I tried using my old trusty FC4 using all kinds of settings, made no difference it doesn´t work either.

If I try a different target, for example 18F4550, for which I had some hardware available, It works perfectly..

I have been studying the datasheet för the PIC18(L)F14K50 very carefully, tried different OSCCON settings and so on
but can´t really see were I´m failing? Could there be a problem in the MCU definition?

Any suggestions?

Best regards.
Nick

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: USB serial(PIC18LF14K50) not working.

Post by electronick »

Hi again.

After som more testing and reading the datasheet I can tell that the configuration setting for PIC18LF14K50 are being set improperly
by FC10.
For example:
Line 3 in the configure screen says: HS-PLL enabled freq=4XFosc1
That is not correct, as it results in: External RC oscillator, CLKOUT function on OSC2.

If someone at Matrix maybe has som opportunity to look into the entire config I would be a very happy man, as it all seems a bit strange.
That includes setting the USB peripheral.

Regards
Nick

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: USB serial(PIC18LF14K50) not working.

Post by Steve-Matrix »

Have you tried creating a simple "1-second flasher" program? That's a good way to confirm your configuration clock settings are correct for your hardware.

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: USB serial(PIC18LF14K50) not working.

Post by electronick »

Hi steve.

Yes I have, with a period time of 100ms(2x 50ms) I get a freq of 9.9785Hz(measure by oscilloscope) but I´m not sure about the accuracy of rest of the configuration settings regarding the oscillator and so on.

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: USB serial(PIC18LF14K50) not working.

Post by Steve-Matrix »

The clock requirements for USB are fairly strict. In the device manual on p23-4 it specifies HS mode with a frequency of 6MHz, 12MHz or 48MHz. Are you using that mode and what crystal are you using with the hardware?

electronick
Posts: 13
Joined: Tue Dec 08, 2020 3:10 pm
Has thanked: 5 times

Re: USB serial(PIC18LF14K50) not working.

Post by electronick »

Hi Steve.

Thanks a lot for looking into this.

MCU running @48MHz
12Mhz crystal on PCB.
Attached the file.

Regards
Nick
Attachments
Test_USBserial_18llf14k50.fcfx
(10.5 KiB) Downloaded 111 times

Steve-Matrix
Matrix Staff
Posts: 1253
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 167 times
Been thanked: 277 times

Re: USB serial(PIC18LF14K50) not working.

Post by Steve-Matrix »

The config looks correct as far as I can tell. You could try disabling the fail-safe monitor.

Another thing I noticed in the datasheet is for USB low speed, the system clock should be no higher than 24MHz. So you could try changing the CPUDIV config setting to "div by 2" and also change Flowcode's clock speed entry to 24MHz so it knows what the actual system clock frequency is.

Also check the hardware - e.g. the USB power mode circuitry (ch 22.6) and no pull-up resistors are used (because the code looks like it sets the internal ones for high speed usb).

Bear in mind it's been a while since I've done any USB development.

Post Reply