📄 misc.c
字号:
#include "typedef.h"
#include "misc.h"
/***************************************************************************
Declaration : delay(u16 dat)
Description : delay (dat) uS
Notice : u16 is 16Bit,Maxim Value = 65535
***************************************************************************/
void delay(u16 dat)
{
// for(i=0; i<dat; i++)
while(--dat)
{
_nop_();
_nop_();
_nop_();
_nop_();
// _nop_();
// _nop_();
}
}
/***************************************************************************
Declaration : void init_mcu(void)
Description : Initializes the MCU
***************************************************************************/
/*void init_mcu(void)
{
P3MDIN = 0xff;
P3MDOUT = ~IO_INIT_B;
P3 = 0xff;
XBR1 = 0x40; // Enable Crossbar
TR0 = 0;
TR1 = 0;
TR2 = 0;
EX0 = 0;
EX1 = 0;
}
*/
//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters : None
//
// This function initializes the system clock and USB clock.
//
//-----------------------------------------------------------------------------
void SYSCLK_Init (void)
{
OSCICN |= 0x03; // Configure internal oscillator for
// its maximum frequency
CLKMUL = 0x00; // Select internal oscillator as
// input to clock multiplier
CLKMUL |= 0x80; // Enable clock multiplier
delay(1000);
CLKMUL |= 0xC0; // Initialize the clock multiplier
// CLKMUL |= 0x20;
while(!(CLKMUL & 0x20)); // Wait for multiplier to lock
CLKSEL |= USB_4X_CLOCK; // Select USB clock
CLKSEL |= SYS_4X_DIV_2; // Select SYSCLK as Clock Multiplier/2
}
/*The produce for configuring and enabling the 4x clock Multiplier is as Follow:
1.Reset the Multiplier by writting 0x00 to register CLKMUL
2.Select the Multiplier input source via the Multiplier bits
3.Enable the Multiplier with the MULEN bit(MUCLK|=0x80)
4.Delay for > 5 us
5.Initialize the Multiplier with the MULINIT bits(CLKMUL|=0xC0)
6.Poll for MULDRY>='1'
Add By lsy */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -