PLL0 Issues, doesn't seem to change the clock rate!

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PLL0 Issues, doesn't seem to change the clock rate!

803 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 01:32:41 MST 2011
So I have this LED blinker example running. Now I want to initiate to PLL0 and clock the system at a much higher frequency. I can send all the values for the PLL0, wait for it to lock on, and all of this works well. However, I do not notice a difference in the speed of the LED blinking. What am I missing? Why isn't the LED blinking faster? My PLL0 output should be around 84~MHz. My values are 0x01 for CLKSRCSEL, 0x0015013A for PLL0CFG, and CCLKCFG has a value of 0x00000003. I made my example in both C with the CMSIS lib and in pure ASM. They both blink perfectly fine.. but the speed is the same as it was with the default values of RESET! What gives?
0 Kudos
Reply
11 Replies

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Tue Nov 15 11:20:47 MST 2011
Finally got some time to run your code.
The version without PLL enabled (your original code) has almost 100 ms between each toggle of P0.22, with the PLL enabled (I added the "ldr r3, = PLL0CON") this is 3.492 ms.

The 'original' version runs on a 12 MHz crystal (with the CCLKCFG set to CCLK/4) so with a little math we can deduce that the CPU indeed runs at 85.9 MHz.

I've attached two pictures showing the results of my logic analyzer.
The updated code can be found via this link.

To be able to download the code using Flash Magic (my current board has no LPC-Link attached) I added some post build commands in the project to generate the .hex file needed.

Regards,[INDENT]Rob
[/INDENT][IMG]http://bikealive.nl/img-for-others/LPCXpresso-forum/20111115-1.png[/IMG]

[IMG]http://bikealive.nl/img-for-others/LPCXpresso-forum/20111115-2.png[/IMG]
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sun Nov 13 03:24:49 MST 2011
Thank you! Yes I will definitely use the archiving system next time. I didn't even realize that was there! The wasn't ready to be used as an example yet but I could tidy it up and share it! I of course can't take credit for anything but the PLL code though. I'd like to study some disassembled C code to see how gcc outputs it to ensure my arm code is tight/clean, but other than that I just enjoy working directly with the machine. Then I only have myself to blame and not a high level language that generates assembler in magical ways. :)
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Nov 13 00:55:57 MST 2011

Quote: beefok
Oh my god.. I just found the bug! I wasn't connecting it properly at line 100... I forgot to change the r3 register back to = PLL0CON
>_<



Bug, mammoth, whatever you call it is fine with me.
Good thing you now really woke up ;)

It is indeed very easy to oversee such a small thing in assembly.
Still, nice to see that you are still brave enough to get you hands dirty on some assembly code :D. I used to program in ARM7 assembly from 1999-2004 almost on a daily basis, most of this was startup code, high speed interrupt drivers etc. It almost seems that with the newer and faster MCUs and programming environments this becomes an extinct profession.

I can recommend this piece of code to anyone wanting to get his/her hands dirty on some (stand alone) assembly. It is nice, compact, readable and has (for me that is) the right level of comments.

Just one tip; when sharing a project with others it is best to export the project using the "export projects to archive (zip)" found in the "Import and export" tab in the quick pane (left bottom of the screen in LPCXpresso).
That way we can import it into a newly created workspace through the "import archived projects (zip)" withou having to use any external zip/unzip tools.

I'll give to code a try next week, then I'll be able to provide you with some numbers regarding blink rate when looking at the signal on my logic analyzer.

Cheers,

Rob
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 11:09:58 MST 2011
Oh my god.. I just found the bug! I wasn't connecting it properly at line 100... I forgot to change the r3 register back to = PLL0CON
>_<

The correct instructions for connecting it back up should be:

                ldr r3, = PLL0CON
                mov r4, #0x03                @ connect PLL0 (and keep it enabled)
                str r4, [r3]
                str r0, [r2]                @ feed sequence
                str r1, [r2]
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 10:49:42 MST 2011
One last thing: the PLL0 code starts at line 58 and ends at 103
Systick timer is off (by default)

Please be careful running the code since it changes the CCLK and PLL0, if it locks you out of programming it again, you need to have your ISP pin and nRESET ready to be used to reprogram it!
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 10:48:05 MST 2011
I don't have an oscilloscope on hand so it's rather tough to be able to really say how fast it's blinking. That may be my biggest problem, but between the default timing of the cpu and the change to main oscillator/PLL0 I was thinking it would jump to a much higher blink-rate even without an oscilloscope to check my results..! There is no visible difference between commenting out my PLL0 code and not commenting it out.
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 10:41:48 MST 2011
Sorry for taking so long, I was asleep! :)

http://dl.dropbox.com/u/1071943/lpc17_pureasm.rar

It's based on the pureasm example that I saw on here: http://knowledgebase.nxp.com/showpost.php?p=8192&postcount=11
which is further based on this:
http://pygmy.utoh.org/riscy/cortex/led-lpc17xx.html

Now, you can load up the my example directly into LPCxpresso IDE, and compile it/debug it/execute it with no problems. The only problem is I seem to have is that LED2 of my LPCXPRESSO 1769 board won't blink at a different (faster) rate once I turn on the main oscilllator and PLL0. I hope you can understand my assembler, it's not optimized at all and I'm just playing around so far. I pretty much converted the instructions from SystemInit(void) into assembler from system_LPC17xx.c which is from the CMSISv2p00_LPC17xx library line for line..
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sat Nov 12 09:49:28 MST 2011
The PLLs work fine for me, must be your code.

Best thing is to post your code and tell us which MCU you a using.

Rob
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Nov 12 02:35:26 MST 2011

Quote:

...this LED blinker example...

Could be useful if you tell us what you are doing, I can't find a 'this LED blinker' sample in my example folder :rolleyes:

Note: PLL0CFG=0x0015013A is a valid and working value. CLKOUT/10 shows a nice 8.59 MHz signal :eek:
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by beefok on Sat Nov 12 02:22:05 MST 2011

Quote: Zero
About 85,9

Does your sample use SysTick with something like:

SysTick_Config(SystemCoreClock / 1000);
Then this timer is set to 1ms = 1/1000 of system clock and the real clock value doesn't matter  :eek:



Unless by default the systick timer is on in the mcu, no. I know that for a fact with my purely assembler example! The systick timer should be off. I can upload the code -- i dont mind! But I have to leave for a few hours. I was just wondering if anyone has dealt with this too?
0 Kudos
Reply

786 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Nov 12 02:17:36 MST 2011

Quote: beefok
My PLL0 output should be around 84~MHz..


Around 85,9

Does your sample use SysTick with something like:

SysTick_Config(SystemCoreClock / 1000);
Then this timer is set to 1ms = 1/1000 of system clock and the real clock value doesn't matter  :eek:
0 Kudos
Reply