📄 f34x_init.c
字号:
//-----------------------------------------------------------------------------
// F34x_Init.c
//-----------------------------------------------------------------------------
// Copyright 2006 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// Contains Initialization Routines for the F340.
//
// FID:
// Target: C8051F34x
// Tool chain: Keil C51 7.20 / Keil EVAL C51
// Silicon Laboratories IDE version 2.72
// Command Line: See Readme.txt
// Project Name: CP220x_Ethernet_Routines
//
//
//
// Release 1.1
// - Configures C8051F120 SYSCLK to 98 MHz
//
// Release 1.0
// -Initial Release (FB)
// -30 MAY 2006
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "global.h"
#if(MCU == F020)
sfr16 DP = 0x82; // 数据指针
sfr16 TMR3RL = 0x92; // 定时器3重装值
sfr16 TMR3 = 0x94; // 定时器3计数器
sfr16 ADC0 = 0xbe; // ADC0数据
sfr16 ADC0GT = 0xc4; // ADC0大于窗口
sfr16 ADC0LT = 0xc6; // ADC0小于窗口
sfr16 RCAP2 = 0xca; // 定时器2捕捉/重装
sfr16 T2 = 0xcc; // 定时器2
sfr16 RCAP4 = 0xe4; // 定时器4捕捉/重装
sfr16 T4 = 0xf4; // 定时器4
sfr16 DAC0 = 0xd2; // DAC0数据
sfr16 DAC1 = 0xd5; // DAC1数据
//-----------------------------------------------------------------------------
// 全局常量
//-----------------------------------------------------------------------------
#define SYSCLK 22118400 // 系统时钟频率Hz
#define BAUDRATE 19200 // UART波特率bps
#define SAMPLERATE0 50000 // ADC0采样频率Hz
#define NUM_SAMPLES 2048 // ADC0采样次数
#define TRUE 1
#define FALSE 0
sbit LED = P1^6; // LED=’1’ 意为开
sbit SW1 = P3^7; // SW1=’0’ 意为按压开关
//sbit CS2200 = P5;
//-----------------------------------------------------------------------------
// 16-bit SFR Definitions for 'F34x
//-----------------------------------------------------------------------------
sfr16 TMR2RL = 0xca; // Timer2 reload value
sfr16 TMR2 = 0xcc; // Timer2 counter
//-----------------------------------------------------------------------------
// Local Constants
//-----------------------------------------------------------------------------
#if(BOARD == CP2201EB)
sbit AB4_RST = P0^6;
#else
sbit AB4_RST = P1^0;
// sbit AB4_RST = P0^3;
#endif
char xdata *buf00;
//-----------------------------------------------------------------------------
// Local Global Variables
//-----------------------------------------------------------------------------
static unsigned int timeout;
//-----------------------------------------------------------------------------
// Exported Function Prototypes
//-----------------------------------------------------------------------------
void Reset_Init(void);
void SYSCLK_Init (void);
void wait_ms(int ms);
void CP220x_RST_Low(void);
void CP220x_RST_High(void);
#if(UART_ENABLED)
char _getkey ();
char putchar (char c);
#endif
//-----------------------------------------------------------------------------
// Local Function Prototypes
//-----------------------------------------------------------------------------
void PORT_Init (void);
void EMIF_Init (void);
#if(UART_ENABLED)
void UART0_Init (void);
#endif
//-----------------------------------------------------------------------------
// Exported Functions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Reset_Init
//-----------------------------------------------------------------------------
void Reset_Init(void)
{
// Disable Watchdog timer
// PCA0MD &= ~0x40; // WDTE = 0 (clear watchdog timer
// enable)
// WDTCN &=~0x40;
WDTCN = 0xde; // 禁止看门狗定时器
WDTCN = 0xad;
// Initialize the MCU
PORT_Init();//端口初始化,这里主要是020的初始化
SYSCLK_Init();//外部振荡器初始化
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -