Page 1 of 1
PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 10:46 am
by Sparkoids
The timings on this device are all wrong it seems.
I have set up the config correctly in MPLAB but it just runs WAY too slowly which is affecting everything else.
Upon compiling in Flowcode the following error occurs: "Caution: Delay inaccurrate: 'delay_ms', Delay overhead:0ms, Unit delay:1.00016ms, Delay resolution:1 units"
Then the device runs so slowly it is not real - the 12Mhz xtal checks OK and the Microchip Settings from the datasheet are set up OK in MPLAB as well.
Primary Clock Enabled
(PCLKEN = ON)
HS Oscillator Set
(FOSC = HS)
USB Clock from OSC1/OSC2 divided by 2
(USBDIV = ON)
Oscillator multiplied by 4
(PLLEN = ON)
CPU System Clock divided by 2
(CPUDIV = CLKDIV2)
I am trying to implement a USB keyboard which works correctly on the ECIO 28 and ECIO 40 but not on this wretched PIC18F13K50 device.
Before I tear out what little hair I have left, has anyone actually run this PIC as a USB device of any description that can help please.....
James :-{
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 11:31 am
by Sparkoids
On a 1 second delay in Flowcode to flash an LED the chip flashes almost exactly 8 times too slowly ie it takes 8 seconds on a 1 second delay.
Even allowing for my reaction time to press the iPhone stopwatch, the propogation delay in that circuitry, the time for the LED to become forward biased to light (1.5uS is it?), the time for the light to reach my eyes at 299792458 metres per second and the time for my brain to allow my finger to react this is still *way* off.
It seems too coincidental to be operating 8 times too slowly though.
Any ideas please....
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 11:39 am
by Sparkoids
OK it was the CPUDIV setting. By setting it to "No CPU System Clock Divide" it runs at the 1 second timing...
...meaning it is a Config setting that is incorrect and therefore my question is this:
Does anyone have the correct settings for this device to enable the USB bus please - the Microchip Datasheet is incorrect (or the code is wrong!)...
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 3:09 pm
by Benj
Hello,
I've been having a play around with the config settings and am having similar difficulties. My guess would be the config files for PPP are slightly incorrect. I will go back through them and check they are correct.
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 3:16 pm
by Benj
Right I think I have found the cause of the problem. The oscillator setting HS+PLL4 is incorrect. You should instead use the HS setting for the oscillator and this should then work correctly. I will make sure this gets fixed in the next update of Flowcode.
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 3:33 pm
by Sparkoids
Beat you to it Ben! Mind you it was trial and error but hey
Anyway I now can "see" a Keyboard in the Mac OSX (but not Windows 7 interestingly) despite it being in Bootcamp.
Anyway the new problem is upon compiling I get this:
Warning unreferenced functions removed:
FCI_FLOAT_TO_STRING in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
FCI_NUMBER_TO_HEX in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
FCI_STRING_TO_INT in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
FCI_STRING_TO_FLOAT in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
Wdt_Delay_S in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
isinf in: C:\Program Files (x86)\Matrix Multimedia\Flowcode V4\FCD\internals.h
usb_get_state in: c:\PROGRA~2\MATRIX~1\FLOWCO~1\boostc\include\USB\pic_usb.c
FCD_USBHID0_UpdateData in: C:\Users\Windows_7\Documents\TestHID.c
FCD_USBHID0_SendData in: C:\Users\Windows_7\Documents\TestHID.c
FCD_USBHID0_ReceiveString in: C:\Users\Windows_7\Documents\TestHID.c
And I presume without being able to send data that may explain why the thing is just sitting there. Any ideas?
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 4:29 pm
by Steve
These are warnings and can safely be ignored.
Re: PIC18F13K50 - Still have timing problems...
Posted: Fri Oct 21, 2011 4:41 pm
by Sparkoids
Thanks Steve. I'm now getting this
Flowcode1.c
Starting preprocessor: c:\PROGRA~2\MATRIX~1\FLOWCO~1\boostc\pp.exe Flowcode1.c -i c:\PROGRA~2\MATRIX~1\FLOWCO~1\boostc\include -d _PIC18F13K50 -la -c2 -o Flowcode1.pp -v -d _BOOSTC -d _PIC18 -d _CHAR_INDEX
...
Flowcode1.c(191): error: general error
Flowcode1.c(191): error: failure
When I'm just trying to flash an LED!
What's worse is it is never consistant and frankly I wish I'd never heard of the PICF1813K50 and just used the one in the ECIO

Re: PIC18F13K50 - Still have timing problems...
Posted: Sat Oct 22, 2011 4:05 pm
by Sparkoids
For anyone interested in this device that is trying to implement USB and is using MPLAB or similar to dump the Flowcode hex to the chip here are the settings that work every time...
CPUDIV - CPU SYSTEM CLOCK / 2
USBDIV - OSC1/OSC2 / 2
FOSC - HS OSCILLATOR
PLLEN - OSCILLATOR * 4
FCMEN - FAIL SAFE CLOCK DISABLED
IESO - OSCILLATOR SWITCHOVER DISABLED
PWRTEN - PWRT ENABLED
BOREN - RESET ENABLED - HARDWARE ONLY
BORV - VBOR SET TO 3.0V NOMINAL
WDTEN - WDT CONTROLLED BY SWDTEN
WDTPS - 1:32768
HFOFST - DO NOT WAIT FOR OSCILLATOR
MCLRE - MCLR PIN ENABLED
STVREN - STACK FULL / UNDERFLOW RESETS
LVP - SINGLE SUPPLY ICSP DISABLED
BBSIZ - 1KW BOOT BLOCK SIZE
XINST - INSTRUCTION SET / EXTENSION ENABLED
I know it is a pain to have to keep setting these up but using them means it programs properly everytime and it looks like Ben has the issue in hand for the next Flowcode revision.
Now all I need to do is get the code working!!