Processor Frequency (speed)

19 Apr 2012

Dear all,

May I know how can I change the processor speed in mbed? I want to run mbed at 60MHz, 100MHz and in overclocked mode. Please help me with this

Thanks

19 Apr 2012

Here's a link to the LPC1768 user manual. It describes the details on what needs to be done to change the MCU's clock speed. It's on chapter 4.

http://www.nxp.com/documents/user_manual/UM10360.pdf

The basic steps normally include turning the HSE, setting the PLL multipliers, using the HSE as the PLL source, and switching the sysclock source to the PLL to change a clock speed

19 Apr 2012

Thank you very much. But if I don't configure anything (for ex, hello world program given in this site) here in the compiler for mbed, the processor will run at 12MHz. right?

19 Apr 2012

it runs on 96MHz I believe. Somewhere in the initialization library sets it to that speed

19 Apr 2012

Hello Sujay,

You can try to refer this link

mbed.org/forum/mbed/topic/229/?page=1

Hope this will help you.

:)

24 Apr 2012

This is a recent dump of the SystemInit() routine used for the mbed1768 with my comments.

; SystemInit (from capi.ar)
; Initializes the LPC1768 clocks and peripherals
SystemInit:
; Set base pointer (r0) to 0x400FC000
00001D50  481B       LDR R0, .+112 ; .+112 == 0x1DC0
; Enable main oscillator
00001D52  2120       MOVS R1, #32 ; 32 == 0x20
00001D54  F8C0 11A0  STR.W R1, [R0, #+416] ; +416 == +0x1A0
; Wait for main oscillator to stabilize
00001D58  F8D0 11A0  LDR.W R1, [R0, #+416] ; +416 == +0x1A0
00001D5C  F011 0F40  TST R1, #0x00000040
00001D60  D0FA       BEQ .-8 ; .-8 == 0x1D58
; Set CPU clock to PLL0 / 3 = 288 MHz / 3 = 96 MHz
00001D62  2102       MOVS R1, #2 ; 2 == 0x2
00001D64  F8C0 1104  STR.W R1, [R0, #+260] ; +260 == +0x104
; Configure PLL0 to use main oscillator as its input
00001D68  2101       MOVS R1, #1 ; 1 == 0x1
00001D6A  F8C0 110C  STR.W R1, [R0, #+268] ; +268 == +0x10C
; PLL0 multiplier set to 11+1=12  12 MHz * 12 * 2 = 288 MHz
00001D6E  220B       MOVS R2, #11 ; 11 == 0xB
00001D70  F8C0 2084  STR.W R2, [R0, #+132] ; +132 == +0x84
; Set enable for PLL0 but not completed until the PLL is fed
00001D74  F8C0 1080  STR.W R1, [R0, #+128] ; +128 == +0x80
; Feed PLL0
00001D78  22AA       MOVS R2, #170 ; 170 == 0xAA
00001D7A  F8C0 208C  STR.W R2, [R0, #+140] ; +140 == +0x8C
00001D7E  2355       MOVS R3, #85 ; 85 == 0x55
00001D80  F8C0 308C  STR.W R3, [R0, #+140] ; +140 == +0x8C
; Wait for PLL0 to lock
00001D84  F8D0 1088  LDR.W R1, [R0, #+136] ; +136 == +0x88
00001D88  F011 6F80  TST R1, #0x04000000
00001D8C  D0FA       BEQ .-8 ; .-8 == 0x1D84
; Set bit to connect PLL0 but not completed until PLL is fed
00001D8E  2103       MOVS R1, #3 ; 3 == 0x3
00001D90  F8C0 1080  STR.W R1, [R0, #+128] ; +128 == +0x80
; Feed PLL0
00001D94  F8C0 208C  STR.W R2, [R0, #+140] ; +140 == +0x8C
00001D98  F8C0 308C  STR.W R3, [R0, #+140] ; +140 == +0x8C
; Set USB clock to PLL0 clock divided by 5+1=6  288 MHz / 6 = 48 MHz
00001D9C  2105       MOVS R1, #5 ; 5 == 0x5
00001D9E  F8C0 1108  STR.W R1, [R0, #+264] ; +264 == +0x108
; Set all peripheral clocks to PLL0 / 4  288 MHz / 4 = 72 MHz
00001DA2  2100       MOVS R1, #0 ; 0 == 0x0
00001DA4  F8C0 11A8  STR.W R1, [R0, #+424] ; +424 == +0x1A8
00001DA8  F8C0 11AC  STR.W R1, [R0, #+428] ; +428 == +0x1AC
; Enable all peripherals by writing 0x042887DE to 0x400FC0C4
00001DAC  4A05       LDR R2, .+24 ; .+24 == 0x1DC4
00001DAE  F8C0 20C4  STR.W R2, [R0, #+196] ; +196 == +0xC4
; Set external CLKOUT signal to CPU Clock
00001DB2  F8C0 11C8  STR.W R1, [R0, #+456] ; +456 == +0x1C8
; Set FLASH MAM to use 4 clocks
00001DB6  F243 013A  MOVW R1, #0x303A ; 0x303A == 12346
00001DBA  6001       STR R1, [R0, #0] ; 0 == 0x0
; Return to caller
00001DBC  4770       BX LR
; Function literals
00001DBE  0000       DCWU 0x0000        ; Padding for 4-byte alignment
00001DC0  C000 400F  DCDU 0x400FC000    ; Base pointer for system control registers
00001DC4  87DE 0428  DCDU 0x042887DE    ; Value used to enable all peripherals