LPCOpen Platform
v1.03
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Modules
Data Structures
Files
Related Pages
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
sysinit_nxp_xpresso_812.c
Go to the documentation of this file.
1
/*
2
* @brief NXP Xpresso LPC812 Sysinit file
3
*
4
* @note
5
* Copyright(C) NXP Semiconductors, 2012
6
* All rights reserved.
7
*
8
* @par
9
* Software that is described herein is for illustrative purposes only
10
* which provides customers with programming information regarding the
11
* LPC products. This software is supplied "AS IS" without any warranties of
12
* any kind, and NXP Semiconductors and its licensor disclaim any and
13
* all warranties, express or implied, including all implied warranties of
14
* merchantability, fitness for a particular purpose and non-infringement of
15
* intellectual property rights. NXP Semiconductors assumes no responsibility
16
* or liability for the use of the software, conveys no license or rights under any
17
* patent, copyright, mask work right, or any other intellectual property rights in
18
* or to any products. NXP Semiconductors reserves the right to make changes
19
* in the software without notification. NXP Semiconductors also makes no
20
* representation or warranty that such application will be suitable for the
21
* specified use without further testing or modification.
22
*
23
* @par
24
* Permission to use, copy, modify, and distribute this software and its
25
* documentation is hereby granted, under NXP Semiconductors' and its
26
* licensor's relevant copyrights in the software, without fee, provided that it
27
* is used in conjunction with NXP Semiconductors microcontrollers. This
28
* copyright, permission, and disclaimer notice must appear in all copies of
29
* this code.
30
*/
31
32
#include "
board.h
"
33
55
/*****************************************************************************
56
* Private types/enumerations/variables
57
****************************************************************************/
58
59
/*****************************************************************************
60
* Public types/enumerations/variables
61
****************************************************************************/
62
63
/*****************************************************************************
64
* Private functions
65
****************************************************************************/
66
67
/* Setup system clocking */
68
STATIC
void
SystemSetupClocking
(
void
)
69
{
70
#if (LPC8XX_USE_XTAL_OSC == 1)
71
#if (CRYSTAL_MAIN_FREQ_IN >= 15000000)
72
Chip_Clock_SetPLLBypass
(
false
,
true
);
/* EXT oscillator >= 15MHz */
73
#else
74
Chip_Clock_SetPLLBypass
(
false
,
false
);
/* EXT oscillator < 15MHz */
75
#endif
76
77
/* Turn on the SYSOSC by clearing the power down bit */
78
Chip_SYSCTL_PowerUp
(
SYSCTL_SLPWAKE_SYSOSC_PD
);
79
80
/* Select the PLL input to the external oscillator */
81
Chip_Clock_SetSystemPllSource
(
SYSCTL_PLLCLKSRC_SYSOSC
);
82
83
#else
84
/* Turn on the IRC by clearing the power down bit */
85
Chip_SYSCTL_PowerUp
(
SYSCTL_SLPWAKE_IRC_PD
);
86
87
/* Select the PLL input in the IRC */
88
Chip_Clock_SetSystemPllSource
(
SYSCTL_PLLCLKSRC_IRC
);
89
#endif
/* defined(LPC8XX_USE_XTAL_OSC) */
90
91
/* Configure the PLL M and P dividers */
92
/* Setup PLL for main oscillator rate (FCLKIN = 12MHz) * 2 = 324Hz
93
MSEL = 1 (this is pre-decremented), PSEL = 2 (for P = 4)
94
FCLKOUT = FCLKIN * (MSEL + 1) = 12MHz * 2 = 24MHz
95
FCCO = FCLKOUT * 2 * P = 24MHz * 2 * 4 = 192MHz (within FCCO range) */
96
Chip_Clock_SetupSystemPLL
(1, 2);
97
98
/* Turn on the PLL by clearing the power down bit */
99
Chip_SYSCTL_PowerUp
(
SYSCTL_SLPWAKE_SYSPLL_PD
);
100
101
/* Wait for PLL to lock */
102
while
(!
Chip_Clock_IsSystemPLLLocked
()) {}
103
104
/* Set system clock divider to 1 */
105
Chip_Clock_SetSysClockDiv
(1);
106
107
/* Setup FLASH access to 2 clocks (up to 30MHz) */
108
Chip_FMC_SetFLASHAccess
(
FLASHTIM_30MHZ_CPU
);
109
110
/* Set main clock source to the system PLL. This will drive 24MHz
111
for the main clock and 24MHz for the system clock */
112
Chip_Clock_SetMainClockSource
(
SYSCTL_MAINCLKSRC_PLLOUT
);
113
114
/* Select the CLKOUT clocking source */
115
Chip_Clock_SetCLKOUTSource
(
SYSCTL_CLKOUTSRC_MAINSYSCLK
, 1);
116
}
117
118
/* Sets up system pin muxing */
119
STATIC
void
SystemSetupMuxing
(
void
)
120
{
121
#if (LPC8XX_USE_XTAL_OSC == 1)
122
/* Use Switch Matrix Tool swm.c file for the Pin Enable 0 variable */
123
LPC_SWM
->PINENABLE0 = 0xffffff82UL;
/* XTALIN + XTALOUT + CLKOUT on PIO0_1 + ACMP_I1 */
124
125
/* Configure the pins for XTALIN/XTALOUT. */
126
LPC_IOCON
->PIO0_8 &= ~(3 << 3);
/* Repeater Mode */
127
LPC_IOCON
->PIO0_9 &= ~(3 << 3);
/* Repeater Mode */
128
129
#else
130
/* Use Switch Matrix Tool swm.c file for the Pin Enable 0 variable */
131
LPC_SWM
->PINENABLE0 = 0xffffffb2UL;
/* IRC + CLKOUT on PIO0_1 + ACMP_I1 */
132
#endif
/* (LPC8XX_USE_XTAL_OSC == 1) */
133
134
/* Assign the CLKOUT function to a pin */
135
LPC_SWM
->PINASSIGN[8] &= ~(0xFE << 16);
/* bits 23:16 = PIN0_x := 1 in this case */
136
137
/* Configure the pin for CLKOUT on PIO0_1 */
138
LPC_IOCON
->PIO0_1 &= ~(3 << 3);
/* Repeater Mode */
139
}
140
141
/*****************************************************************************
142
* Public functions
143
****************************************************************************/
144
152
void
SystemInit
(
void
)
153
{
154
/* Booting from FLASH, so remap vector table to FLASH */
155
Chip_SYSCTL_Map
(
REMAP_USER_FLASH_MODE
);
156
157
/* Enable the clock to the Switch Matrix */
158
Chip_Clock_EnablePeriphClock
(
SYSCTL_CLOCK_SWM
);
159
160
/* Enable the clock for the IOCON */
161
Chip_Clock_EnablePeriphClock
(
SYSCTL_CLOCK_IOCON
);
162
163
/* Setup system clocking and muxing */
164
SystemSetupMuxing
();
165
SystemSetupClocking
();
166
167
/* Disable the clock to the Switch Matrix to save power */
168
Chip_Clock_DisablePeriphClock
(
SYSCTL_CLOCK_SWM
);
169
170
/* IOCON clock left on, but may be turned off in no other IOCON
171
changes are needed */
172
}
173
software
lpc_core
lpc_board
boards_8xx
nxp_xpresso_812
sysinit_nxp_xpresso_812.c
Generated on Fri May 10 2013 10:42:11 for LPCOpen Platform by
1.8.2