I tried the speed test to check code execution time at 24Mhz and 48Mhz. I left the DEFINE OSC 20 for both tests. I used pause loops like Charles suggested, and used 10 minute long tests. I know longer would be better, but I think 10 minutes should show any difference. Both times the LED was on for 10 minutes, the best I could measure with a clock second hand.
I only changed the _CONFIG1L setting "_CPUDIV_OSC1_PLL2_1L" and _CPUDIV_OSC3_PLL4_1L between the tests. So I'm still scratching my head, seems if the CPU was running at 48Mhz but my define is at 20Mhz, it should have taken 4.1 minutes. So it seems the clock speed for code execution is derived directly from the external XTAL?
My A/D sampling frequency is now fast enough for my needs, as long as I keep the rest of my code in check I should be OK. I'd still like to understand why this is happening (or not happening)???
Thanks
Shane
Here is the code I used:
Code:
'_CPUDIV_OSC1_PLL2_1L '48 Mhz
'_CPUDIV_OSC3_PLL4_1L '24 Mhz
DEFINE LOADER_USED 1
asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L ,_BOR_ON_2L & _BORV_2_2L
endasm
DEFINE OSC 20
X VAR Byte
TRISC.0 = 0
Portc.0 = 0
For X = 1 to 10 'Turn LED on for 10 min
PAUSE 60000
Next X
Start:
Portc.0 = 1 'Start Toggling LED
For X = 1 to 10
PAUSE 100
Next X
Portc.0 = 0
For X=1 to 10
Pause 100
Next X
Goto START
Bookmarks