Page 1 of 2
USB serial(PIC18LF14K50) not working.
Posted: Fri Jan 19, 2024 11:23 am
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
Re: USB serial(PIC18LF14K50) not working.
Posted: Fri Jan 19, 2024 2:11 pm
by BenR
Hi Nick,
Do you want to try this and see how you get on.
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 (62.21 KiB) Viewed 5605 times
Re: USB serial(PIC18LF14K50) not working.
Posted: Fri Jan 19, 2024 2:30 pm
by electronick
Hi Ben.
Thank´s a lot
I will try the file you uploaded and give it a try.
regards
Nick
Re: USB serial(PIC18LF14K50) not working.
Posted: Sun Jan 21, 2024 3:02 pm
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
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 11:07 am
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
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 12:09 pm
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.
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 12:33 pm
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.
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 1:33 pm
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?
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 2:14 pm
by electronick
Hi Steve.
Thanks a lot for looking into this.
MCU running @48MHz
12Mhz crystal on PCB.
Attached the file.
Regards
Nick
Re: USB serial(PIC18LF14K50) not working.
Posted: Wed Jan 24, 2024 3:53 pm
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.