⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.c

📁 nec 78K0 样例对程序初始化电表样
💻 C
字号:
/*
*******************************************************************************
**
**  This device driver was created by Applilet for the 78K0/KB2, 78K0/KC2,
**  78K0/KD2, 78K0/KE2 and 78K0/KF2 8-Bit Single-Chip Microcontrollers.
**
**  Copyright(C) NEC Electronics Corporation 2002 - 2005
**  All rights reserved by NEC Electronics Corporation.
**
**  This program should be used on your own responsibility.
**  NEC Electronics Corporation assumes no responsibility for any losses
**  incurred by customers or third parties arising from the use of this file.
**
**  Filename :	system.c
**  Abstract :	This file implements device driver for System module.
**  APIlib :	NEC78K0KX2.lib V1.01 [09 Aug. 2005]
**
**  Device :	uPD78F0513(44-pin)
**
**  Compiler :	NEC/CC78K0
**
*******************************************************************************
*/
/*
*******************************************************************************
**  Include files
*******************************************************************************
*/
#include "macrodriver.h"
#include "system.h"
/*
*******************************************************************************
**  MacroDefine
*******************************************************************************
*/

/*
**-----------------------------------------------------------------------------
**
**  Abstract:
**	Init the Clock Generator and Oscillation stabilization time.
**
**  Parameters:
**	None
**
**  Returns:
**	None
**
**-----------------------------------------------------------------------------
*/
void Clock_Init( void )
{
	UCHAR temp_stabset, temp_stabwait;
	SetIORBit(PM12, 0x06);			/* P121/122 input mode */
	ClrIORBit(OSCCTL, 0x80);		/* X1/X2 input mode */
	SetIORBit(OSCCTL, 0x40);
	ClrIORBit(MOC, 0x80);
	/* OSC stabilization time */
	temp_stabset = CG_X1STAB_STA;
	do{
		temp_stabwait = OSTC;
		temp_stabwait &= temp_stabset;
	}while(temp_stabwait != temp_stabset);
	OSTS = CG_X1STAB_SEL;
	ClrIORBit(OSCCTL, 0x01);		/* 2MHz<=fx<=10MHz */
	SetIORBit(MCM, 0x05);			/* X1 operate for CPU */
	SetIORBit(PM12, 0x18);			/* P123/124 input mode */
	ClrIORBit(OSCCTL, 0x20);		/* XT1 input mode */
	SetIORBit(OSCCTL, 0x10);
	ClrIORBit(RCM, 0x01);
	PCC = CG_CPU_CLOCKSEL;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -