//****************************************************************************************** // Project : LPC810M021FN08 Sample Program // Program Name : // Programer : // Create date : Version 1.0 H25.12.01 // History : // Laungage : //****************************************************************************************** // (1)Description // //****************************************************************************************** #include "LPC8xx.h" void Init_PIN(void); void Init_OSC(void); void Init_CLKOUT(void); int main(void) { // ******************** // 1.Initialized // ******************** // (1)Assign PIN Init_PIN(); // (2)Define CLKOUT Init_CLKOUT(); // ******************** // 2.Main // ******************** while(1); } //****************************************************************************************** // Function Name : Init_PIN // Title : // Input : // Output : // Description : //****************************************************************************************** void Init_PIN(void) { // **************************** // 1.Define Pin assign register 8 // **************************** // PINASSIGN8[7:0] I2C_SCL_IO I2C_SCL function assignment. // The value is the pin number to be assigned to this function. // The following pins are available: PIO0_0 (= 0) to PIO0_17 (= 0x11). // Reset value : 0xFF // PINASSIGN8[15:8] ACMP_O_O ACMP_O_O function assignment. // The value is the pin number to be assigned to this function. // The following pins are available: PIO0_0 (= 0) to PIO0_17 (= 0x11). // Reset value : 0xFF // PINASSIGN8[23:16] CLKOUT_O CLKOUT function assignment. // The value is the pin number to be assigned to this function. // The following pins are available: PIO0_0 (= 0) to PIO0_17 (= 0x11). // Reset value : 0xFF // PINASSIGN8[31:24] GPIO_INT_BMAT_O GPIO_INT_BMAT function assignment. // The value is the pin number to be assigned to this function. // The following pins are available: PIO0_0 (= 0) to PIO0_17 (= 0x11). // Reset value : 0xFF LPC_SWM->PINASSIGN8 = 0xFF01FFFF; } //****************************************************************************************** // Function Name : Init_CLKOUT // Title : // Input : // Output : // Description : //****************************************************************************************** void Init_CLKOUT(void) { // **************************** // 1.Define CLKOUT clock source select register // **************************** // CLKOUTSEL[1:0] SEL CLKOUT clock source 0 Reset value:0 // 0x0 IRC oscillator // 0x1 Crystal oscillator (SYSOSC) // 0x2 Watchdog oscillator // 0x3 Main clock // CLKOUTSEL[31:2] - Reserved Reset value:0 LPC_SYSCON->CLKOUTSEL = 0x000000003; // **************************** // 2.Define CLKOUT clock source update enable register // **************************** // CLKOUTUEN[0] ENA Enable CLKOUT clock source update 0 // 0 No change // 1 Update clock source // CLKOUTUEN[31:1] - Reserved LPC_SYSCON->CLKOUTUEN = 0x00000001; while (!(LPC_SYSCON->CLKOUTUEN & 0x01)); // **************************** // 3.Define CLKOUT clock divider register // **************************** // CLKOUTDIV[7:0] DIV CLKOUT clock divider values // 0: Disable CLKOUT clock divider. // 1: Divide by 1. // to // 255: Divide by 255. // Reset value 0 // CLKOUTDIV[31:8] - Reserved LPC_SYSCON->CLKOUTDIV = 0x00000001; }