📄 system_config.c
字号:
#include "switch_power.h"
void Sysclk_Init(void) // Initialize oscillator
{
OSCICN = 0x83; // configure internal oscillator
CLKSEL = 0x00; // not divide 24.5MHz
RSTSRC = 0x04; // Missing clock detector
// enable missing clock detector
}
/**********************************************************************************
*
*
*
***********************************************************************************/
void Port_Init(void) // Initialize crossbar and GPIO
{
P0MDIN = 0xFF; // 0/analog input1/Not analog input
P0MDOUT = 0xFF; // 0/Open-drain output 1/ set as push-pull
P0SKIP = 0x0f; // P0.0 as Vref P0.1 as IDA P0.2 as X1 P0.3 as X2
P1MDIN = 0xCF; // Port 1 pin 7 set as analog input
P1MDOUT = 0xFF; // Port 1 pins 0-3 set high impedence
P1SKIP = 0x30; // P1.4 and P1.5 as AD input
XBR0 = 0x00;
XBR1 = 0x41; // Enable Crossbar and PCA0(CEX0) at p0.4
}
/**********************************************************************************
*
*
*
***********************************************************************************/
void Interrupt_Init(void)
{
ET2 = 1; // Enable Timer2 interrupt
PT2 = 1; // Set T2 to High priority.
}
/**********************************************************************************
*
*
*
***********************************************************************************/
void WDT_Init(void)
{
}
/**********************************************************************************
*
*
*
***********************************************************************************/
void Vref_Initial(void)
{
REF0CN = 0x0B;//bit 3 vref pin(0) or vdd(1) used as voltage reference
//bit 2 temperature sensor off
//bit 1 internal biase generator on
//bit 0 internal voltage reference driven on the vref pin(0/vdd 1/2.45v)
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -