?? dz60_init.c
字號(hào):
/*******************************************************************************/
/*
Copyright (c) 2007 Freescale Semiconductor
Freescale Confidential Proprietary
\file DZ60_init.c
\brief S08DZ60 initialization
\author Freescale Semiconductor
\author B05114
\version 0.1
\date January/2008
*/
/*******************************************************************************/
/* Derivative peripheral declarations */
#include "derivative.h"
/* Definitions and function prototypes */
#include "DZ60_init.h"
/*******************************************************************************/
/*
* \brief Multipurpose Clock Generator initialization.
* \author B05114
* \param void
* \return void
*/
void MCG_Init(void)
{
/* Common initialization of the write once registers */
/* SOPT1: COPT=0,STOPE=0,SCI2PS=0,IICPS=0,??=0,??=0,??=0 */
(SOPT1=0x00);
/* SOPT2: COPCLKS=0,COPW=0,??=0,ADHTS=0,??=0,MCSEL=0 */
(SOPT2=0x00);
/* SPMSC1: LVWF=0,LVWACK=0,LVWIE=0,LVDRE=1,LVDSE=1,LVDE=1,??=0,BGBE=0 */
(SPMSC1=0x1C);
/* SPMSC2: ??=0,??=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,??=0,PPDC=0 */
(SPMSC2=0x00);
/* System clock initialization */
MCGTRM = *(unsigned char*)0xFFAF; /* Initialize MCGTRM register from a non volatile memory */
MCGSC = *(unsigned char*)0xFFAE; /* Initialize MCGSC register from a non volatile memory */
/* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=0,EREFS=1,ERCLKEN=1,EREFSTEN=0 */
(MCGC2=0x26); /* Set MCGC2 register */
/* MCGC1: CLKS=2,RDIV=7,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
(MCGC1=0xBA); /* Set MCGC1 register */
while(!MCGSC_OSCINIT) { /* Wait until external reference is stable */
}
while(MCGSC_IREFST) { /* Wait until external reference is selected */
}
while((MCGSC & 0x0C) != 0x08) { /* Wait until external clock is selected as a bus clock reference */
}
/* MCGC2: BDIV=0,RANGE=1,HGO=0,LP=1,EREFS=1,ERCLKEN=1,EREFSTEN=0 */
(MCGC2=0x2E); /* Set MCGC2 register */
/* MCGC1: CLKS=2,RDIV=1,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
(MCGC1=0x8A); /* Set MCGC1 register */
/* MCGC3: LOLIE=0,PLLS=1,CME=0,??=0,VDIV=5 */
(MCGC3=0x45); /* Set MCGC3 register */
/* MCGC2: LP=0 */
(MCGC2&=0xf7);
while(!MCGSC_PLLST) { /* Wait until PLL is selected */
}
while(!MCGSC_LOCK) { /* Wait until PLL is locked */
}
/* MCGC1: CLKS=0,RDIV=1,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
(MCGC1=0x0A); /* Set MCGC1 register */
while((MCGSC & 0x0C) != 0x0C) { /* Wait until PLL clock is selected as a bus clock reference */
}
}
/*******************************************************************************/
/*
* \brief DZ60 demo board GPIO settings
* \author B05114
* \param void
* \return void
*/
void GPIO_Init(void)
{
PTBDD_PTBDD3 = 1; /* PTB3 is output to LED2 */
PTBDD_PTBDD6 = 0; /* PTB6 is input from push-button PB1 */
PTBDD_PTBDD7 = 0; /* PTB7 is input from push-button PB2 */
PTCDD_PTCDD5 = 1; /* PTC5 is output to LED1 */
}
/*******************************************************************************/
/*
* \brief Timer TPM1 configuration
* \author B05114
* \param void
* \return void
*/
void TPM1_Init(void)
{
TPM1SC_PS = PS_DIV; /* Prescaler selection */
TPM1SC_CLKSx = BUS_CLK; /* Clock source selection */
TPM1SC_TOIE = 1; /* Timer overflow interrupt enabled */
}
/*******************************************************************************/
/*******************************************************************************/
/* */
/* All software, source code, included documentation, and any implied know-how */
/* are property of Freescale Semiconductor and therefore considered */
/* CONFIDENTIAL INFORMATION. */
/* */
/* This confidential information is disclosed FOR DEMONSTRATION PURPOSES ONLY. */
/* */
/* All Confidential Information remains the property of Freescale Semiconductor*/
/* and will not be copied or reproduced without the express written permission */
/* of the Discloser, except for copies that are absolutely necessary in order */
/* to fulfill the Purpose. */
/* */
/* Services performed by FREESCALE in this matter are performed AS IS and */
/* without any warranty. CUSTOMER retains the final decision relative to the */
/* total design and functionality of the end product. */
/* */
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the */
/* success of this project. */
/* */
/* FREESCALE disclaims all warranties, express, implied or statutory including,*/
/* but not limited to, implied warranty of merchantability or fitness for a */
/* particular purpose on any hardware, software ore advise supplied to the */
/* project by FREESCALE, and or any product resulting from FREESCALE services. */
/* */
/* In no event shall FREESCALE be liable for incidental or consequential */
/* damages arising out of this agreement. CUSTOMER agrees to hold FREESCALE */
/* harmless against any and all claims demands or actions by anyone on account */
/* of any damage,or injury, whether commercial, contractual, or tortuous, */
/* rising directly or indirectly as a result of the advise or assistance */
/* supplied CUSTOMER in connectionwith product, services or goods supplied */
/* under this Agreement. */
/* */
/*******************************************************************************/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -