Beispiel #1
0
/* Board Debug UART Initialisation function */
static void Board_UART_Init(void)
{
	Chip_SYSCTL_Enable_ASYNC_Syscon(true);
	/* Divided by 1 */
	Chip_Clock_SetAsyncSysconClockDiv(1);

	/* UART0 pins are setup in board_sysinit.c */
}
Beispiel #2
0
static void UART_PinMuxSetup(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_54102)
	/* Setup UART TX Pin */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 0, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGITAL_EN));
	/* Setup UART RX Pin */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 1, (IOCON_FUNC1 | IOCON_MODE_INACT | IOCON_DIGITAL_EN));
	Chip_SYSCON_Enable_ASYNC_Syscon(true);	/* Enable Async APB */
	Chip_Clock_SetAsyncSysconClockDiv(1);	/* Set Async clock divider to 1 */
#else
#warning "No UART PIN/CLK setup for this example"
#endif
}
Beispiel #3
0
/* UART Pin mux function - note that SystemInit() may already setup your
   pin muxing at system startup */
static void Init_UART_PinMux(void)
{
#if defined(BOARD_NXP_LPCXPRESSO_54000)
	Chip_Clock_SetAsyncSysconClockDiv(1);	/* divided by 1 */

	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 0, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_DIGITAL_EN | IOCON_INPFILT_OFF);
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 1, IOCON_MODE_INACT | IOCON_FUNC1 | IOCON_DIGITAL_EN | IOCON_INPFILT_OFF);

#else
	/* Configure your own UART pin muxing here if needed */
#warning No UART pin muxing defined
#endif
}
/* Clock and PLL initialization based on the external clock input */
void Chip_SetupExtInClocking(uint32_t iFreq)
{
	PLL_CONFIG_T pllConfig;
	PLL_SETUP_T pllSetup;
	PLL_ERROR_T pllError;

	/* IOCON clock left on, this is needed is CLKIN is used. */
	Chip_Clock_EnablePeriphClock(SYSCON_CLOCK_IOCON);

	/* Select external clock input pin */
	Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, (IOCON_MODE_PULLUP |
											IOCON_FUNC1 | IOCON_DIGITAL_EN | IOCON_INPFILT_OFF));

	/* Select the PLL input to the EXT clock input */
	Chip_Clock_SetSystemPLLSource(SYSCON_PLLCLKSRC_CLKIN);

	/* Setup FLASH access */
	setupFlashClocks(iFreq);

	/* Power down PLL to change the PLL divider ratio */
	Chip_SYSCON_PowerDown(SYSCON_PDRUNCFG_PD_SYS_PLL);

	/* Setup PLL configuration */
	pllConfig.desiredRate = iFreq;
	pllConfig.InputRate = 0;
	pllConfig.flags = PLL_CONFIGFLAG_FORCENOFRACT;
	pllError = Chip_Clock_SetupPLLData(&pllConfig, &pllSetup);
	if (pllError == PLL_ERROR_SUCCESS) {
		pllSetup.flags = PLL_SETUPFLAG_WAITLOCK | PLL_SETUPFLAG_ADGVOLT;
		pllError = Chip_Clock_SetupSystemPLLPrec(&pllSetup);
	}

	/* Set system clock divider to 1 */
	Chip_Clock_SetSysClockDiv(1);

	/* Set main clock source to the system PLL. This will drive 24MHz
	   for the main clock and 24MHz for the system clock */
	Chip_Clock_SetMainClockSource(SYSCON_MAINCLKSRC_PLLOUT);

	/* ASYSNC SYSCON needs to be on or all serial peripheral won't work.
	   Be careful if PLL is used or not, ASYNC_SYSCON source needs to be
	   selected carefully. */
	Chip_SYSCON_Enable_ASYNC_Syscon(true);
	Chip_Clock_SetAsyncSysconClockDiv(1);
	Chip_Clock_SetAsyncSysconClockSource(SYSCON_ASYNC_IRC);
}
/* Set up and initialize clocking prior to call to main */
void Board_SetupClocking(void)
{
	/* The IRC is always the first clock source even if CLK_IN is used later.
	   Once CLK_IN is selected as the clock source. We can turned off the IRC later.
	   Turn on the IRC by clearing the power down bit */
	Chip_SYSCTL_PowerUp(PDRUNCFG_PD_IRC_OSC_EN | PDRUNCFG_PD_IRC_EN);

	//Board_SetupXtalClocking();
	Board_SetupIRCClocking();

	/* Select the CLKOUT clocking source */
	Chip_Clock_SetCLKOUTSource(SYSCTL_CLKOUTSRC_MAINSYSCLK, 1);

	/* ASYSNC SYSCON needs to be on or all serial peripheral won't work.
	   Be careful if PLL is used or not, ASYNC_SYSCON source needs to be
	   selected carefully. */
	Chip_SYSCTL_Enable_ASYNC_Syscon(true);
	Chip_Clock_SetAsyncSysconClockDiv(1);
	Chip_Clock_SetAsyncSysconClockSource(ASYNC_SYSCTL_CLOCK_IRC);
}
/* Clock and PLL initialization based on the internal oscillator */
void Chip_SetupIrcClocking(uint32_t iFreq)
{
	PLL_CONFIG_T pllConfig;
	PLL_SETUP_T pllSetup;
	PLL_ERROR_T pllError;

	/* Turn on the IRC by clearing the power down bit */
	Chip_SYSCON_PowerUp(SYSCON_PDRUNCFG_PD_IRC_OSC | SYSCON_PDRUNCFG_PD_IRC);
        
	/* Select the PLL input to the IRC */
	Chip_Clock_SetSystemPLLSource(SYSCON_PLLCLKSRC_IRC);

	/* Setup FLASH access */
	setupFlashClocks(iFreq);

	/* Power down PLL to change the PLL divider ratio */
	Chip_SYSCON_PowerDown(SYSCON_PDRUNCFG_PD_SYS_PLL);
        
	/* Setup PLL configuration */
	pllConfig.desiredRate = iFreq;  
	pllConfig.InputRate = 0;
	pllConfig.flags = PLL_CONFIGFLAG_FORCENOFRACT;
	pllError = Chip_Clock_SetupPLLData(&pllConfig, &pllSetup);
	if (pllError == PLL_ERROR_SUCCESS) {
		pllSetup.flags = PLL_SETUPFLAG_WAITLOCK | PLL_SETUPFLAG_ADGVOLT;
		pllError = Chip_Clock_SetupSystemPLLPrec(&pllSetup);
	}
        Chip_Clock_SetSysClockDiv(1);
        Chip_Clock_SetMainClockSource(SYSCON_MAINCLKSRC_PLLOUT);
        
        //Chip_Clock_SetCLKOUTSource(SYSCON_CLKOUTSRC_MAINCLK, 1);
	/* ASYSNC SYSCON needs to be on or all serial peripheral won't work.
	   Be careful if PLL is used or not, ASYNC_SYSCON source needs to be
	   selected carefully. */
	Chip_SYSCON_Enable_ASYNC_Syscon(true);
	Chip_Clock_SetAsyncSysconClockDiv(4);
	Chip_Clock_SetAsyncSysconClockSource(SYSCON_ASYNC_MAINCLK);//SYSCON_ASYNC_IRC);//SYSCON_ASYNC_SYSPLLOUT
}