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 :-{
PIC18F13K50 - Still have timing problems...
Moderator: Benj
Re: PIC18F13K50 - Still have timing problems...
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....
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...
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!)...
...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!)...
- 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: PIC18F13K50 - Still have timing problems...
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- 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: PIC18F13K50 - Still have timing problems...
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: PIC18F13K50 - Still have timing problems...
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?
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...
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
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...
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!!
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!!