Test application based on the AVR examples provided by ThaiEasyElec for their ELT240320ATP breakout board -- library works rather slow on the mbed platform.
ClockControl.cpp
- Committer:
- robodude666
- Date:
- 2010-03-10
- Revision:
- 0:4395705c8647
File content as of revision 0:4395705c8647:
#include "ClockControl.h" void setPLL0Frequency(unsigned char clkSrc, unsigned short M, unsigned char N) { LPC_SC->CLKSRCSEL = clkSrc; LPC_SC->PLL0CFG = (((unsigned int)N-1) << 16) | M-1; LPC_SC->PLL0CON = 0x01; LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; while (!(LPC_SC->PLL0STAT & (1<<26))); LPC_SC->PLL0CON = 0x03; LPC_SC->PLL0FEED = 0xAA; LPC_SC->PLL0FEED = 0x55; } void setPLL1Frequency(unsigned char clkSrc, unsigned short M, unsigned char N) { LPC_SC->CLKSRCSEL = clkSrc; LPC_SC->PLL1CFG = (((unsigned int)N-1) << 16) | M-1; LPC_SC->PLL1CON = 0x01; LPC_SC->PLL1FEED = 0xAA; LPC_SC->PLL1FEED = 0x55; while (!(LPC_SC->PLL1STAT & (1<<26))); LPC_SC->PLL1CON = 0x03; LPC_SC->PLL1FEED = 0xAA; LPC_SC->PLL1FEED = 0x55; } unsigned int setSystemFrequency(unsigned char clkDivider, unsigned char clkSrc, unsigned short M, unsigned char N) { setPLL0Frequency(clkSrc, M, N); LPC_SC->CCLKCFG = clkDivider - 1; SystemCoreClockUpdate(); return SystemCoreClock; }