根据楼主的指点,移到LPC1114上是这样的。
有两个问题,LPC1114的默认系统频率到底是哪个?
在工程的system_LPC11xx.c文件中是这样定义的
#define XTAL (12000000UL) /* Oscillator frequency */ #define OSC_CLK ( XTAL) /* Main oscillator frequency */ #define IRC_OSC ( 4000000UL) /* Internal RC oscillator frequency */ #define WDT_OSC ( 250000UL) /* WDT oscillator frequency */
然后下面是这样的:
uint32_t ClockSource = IRC_OSC; uint32_t SystemFrequency = IRC_OSC; /*!< System Clock Frequency (Core Clock) */ uint32_t SystemAHBFrequency = IRC_OSC;
然后主程序是
#include "LPC11xx.h" #include "system_LPC11xx.h" #define DELAY_LEN 1000 volatile uint32_t msTicks; void SysTick_Handler(void); static void Delay (uint32_t dlyTicks); #define LED (1<<5) /* LED D1 connect to PIO3_5 */
int main (void) { SystemInit();
/* Enable AHB clock to the GPIO domain. */ LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6); LPC_GPIO3->DIR |= LED; // pin output
//LPC1114 默认时钟也是4MHz ???
SysTick_Config(SystemFrequency/1000);
while (1) { LPC_GPIO3->DATA ^= LED; // reset pin : LED light Delay (DELAY_LEN); } }
void SysTick_Handler(void) { msTicks++; }
static void Delay (uint32_t dlyTicks) { uint32_t curTicks; curTicks = msTicks; while ((msTicks - curTicks) < dlyTicks); }
[ 本帖最后由 zgl198905 于 2011-2-24 13:09 编辑 ] |