?? stcmcu+
字號(hào):
/*------------------------------------------------*/
/* --- 宏晶科技 STCMCU ---------------------------*/
/* --- Mobile: (86)13922805190 -------------------*/
/* --- Fax: 86-755-82944243 ----------------------*/
/* --- Tel: 86-755-82948412 ----------------------*/
/* --- Web: www.STCMCU.com -----------------------*/
/* 適用于: STC12C56xx STC12LE56xx ------------*/
/* ------- STC12C56xxAD STC12LE56xxAD ----------*/
/*------------------------------------------------*/
#ifndef __STC12C56_H__
#define __STC12C56_H__
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr PSW = 0xd0; //程序狀態(tài)字 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 CY AC F0 RS1 RS0 OV F1 P
//初始值=0000,0000 0 0 0 0 0 0 0 0
sbit CY = PSW^7; //進(jìn)位標(biāo)志
sbit AC = PSW^6; //輔助進(jìn)位標(biāo)志
sbit F0 = PSW^5; //用戶標(biāo)志
sbit RS1 = PSW^4; //寄存器組選擇位1
sbit RS0 = PSW^3; //寄存器組選擇位0
sbit OV = PSW^2; //溢出標(biāo)志
sbit P = PSW^0; //ACC的偶校驗(yàn)位
/////////////////////////////////
sfr ACC = 0xe0; //累加器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
sbit ACC7 = ACC^7; //累加器第7位
sbit ACC6 = ACC^6; //累加器第6位
sbit ACC5 = ACC^5; //累加器第5位
sbit ACC4 = ACC^4; //累加器第4位
sbit ACC3 = ACC^3; //累加器第3位
sbit ACC2 = ACC^2; //累加器第2位
sbit ACC1 = ACC^1; //累加器第1位
sbit ACC0 = ACC^0; //累加器第0位
/////////////////////////////////
sfr B = 0xf0; //B寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr SP = 0x81; //堆棧指針 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0111 0 0 0 0 0 1 1 1
/////////////////////////////////
sfr DPL = 0x82; //數(shù)據(jù)指針低字節(jié) Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr DPH = 0x83; //數(shù)據(jù)指針高字節(jié) Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr PCON = 0x87; //電源控制寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 SMOD SMOD0 LVDF POF GF1 GF0 PD IDL
//初始值=0011,0000 0 0 1 1 0 0 0 0
#define SMOD 0x80 //串口波特率倍速位,置1可使波特率快1倍
#define SMOD0 0x40 //FE/SM0選擇位,0:SCON.7為SM0 1:SCON.7為FE
#define LVDF 0x20 //低壓檢測(cè)中斷請(qǐng)求位,由硬件置1,需由軟件清0
#define POF 0x10 //上電復(fù)位標(biāo)志位,上電時(shí)由硬件置1,需由軟件清0
#define GF1 0x08 //通用標(biāo)志位1
#define GF0 0x04 //通用標(biāo)志位0
#define PD 0x02 //掉電控制位,寫(xiě)1可以使MCU進(jìn)入PowerDown模式
#define IDL 0x01 //空閑控制位,寫(xiě)1可以使MCU進(jìn)入Idle模式
/////////////////////////////////
sfr WAKE_CLKO = 0x8f; //掉電喚醒/時(shí)鐘輸出控制 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 PCAWAKEUP RXDPINIE T1PINIE T0PINIE - - T1VLKO T0CLKO
//初始值=0000,xx00 0 0 0 0 x x 0 0
#define PCAWAKEUP 0x80 //允許PCA的上升沿/下降沿中斷喚醒掉電MCU
#define RXD_PIN_IE 0x40 //允許RXD(P3.0)下降沿置位RI中斷時(shí)喚醒掉電MCU(必須打開(kāi)相應(yīng)中斷)
#define T1_PIN_IE 0x20 //允許T1(P3.5)下降沿置位T1中斷時(shí)喚醒掉電MCU(必須打開(kāi)相應(yīng)中斷)
#define T0_PIN_IE 0x10 //允許T0(P3.4)下降沿置位T0中斷時(shí)喚醒掉電MCU(必須打開(kāi)相應(yīng)中斷)
#define T1CLKOEN 0x02 //打開(kāi)P3.5腳的定時(shí)器1時(shí)鐘溢出脈沖,輸出的時(shí)鐘頻率為1/2倍的T1溢出率
#define T0CLKOEN 0x01 //打開(kāi)P3.4腳的定時(shí)器0時(shí)鐘溢出脈沖,輸出的時(shí)鐘頻率為1/2倍的T0溢出率
/////////////////////////////////
sfr CLK_DIV = 0xc7; //時(shí)鐘分頻寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - - - - - CLKS2 CLKS1 CLKS0
//初始值=xxxx,x000 x x x x x 0 0 0
#define FOSCD1 0x00 //系統(tǒng)時(shí)鐘為Fosc
#define FOSCD2 0x01 //系統(tǒng)時(shí)鐘為Fosc/2
#define FOSCD4 0x02 //系統(tǒng)時(shí)鐘為Fosc/4
#define FOSCD8 0x03 //系統(tǒng)時(shí)鐘為Fosc/8
#define FOSCD16 0x04 //系統(tǒng)時(shí)鐘為Fosc/16
#define FOSCD32 0x05 //系統(tǒng)時(shí)鐘為Fosc/32
#define FOSCD64 0x06 //系統(tǒng)時(shí)鐘為Fosc/64
#define FOSCD128 0x07 //系統(tǒng)時(shí)鐘為Fosc/128
/////////////////////////////////
sfr WDT_CONTR = 0xe1; //看門(mén)狗定時(shí)器控制器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 WDT_FLAG - EN_WDT CLR_WDT IDL_WDT PS2 PS1 PS0
//初始值=0x00,0000 0 x 0 0 0 0 0 0
#define WDT_FLAG 0x80 //看門(mén)狗復(fù)位標(biāo)志,當(dāng)看門(mén)狗溢出產(chǎn)生復(fù)位后,硬件自動(dòng)置1,需要由軟件清0
#define EN_WDT 0x20 //軟件使能看門(mén)狗,打開(kāi)后不能用軟件的方式關(guān)閉
#define CLR_WDT 0x10 //清看門(mén)狗定時(shí)器
#define IDLE_WDT 0x08 //IDLE模式下,看門(mén)狗定時(shí)器是否繼續(xù)計(jì)時(shí)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr AUXR = 0x8e; //輔助寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 T0x12 T1x12 UM0x6 EADCI ESPI ELVDI - -
//初始值=0000,00xx 0 0 0 0 0 0 x x
#define T0x12 0x80 //定時(shí)器0時(shí)鐘控制,0:Fosc/12(傳統(tǒng)的12分頻) 1:Fosc/1(1T模式,不分頻,即12倍于傳統(tǒng)速度)
#define T1x12 0x40 //定時(shí)器1時(shí)鐘控制,0:Fosc/12(傳統(tǒng)的12分頻) 1:Fosc/1(1T模式,不分頻,即12倍于傳統(tǒng)速度)
#define UR0x6 0x20 //串口模式0的時(shí)鐘控制,0:Fosc/12(傳統(tǒng)的12分頻) 1:Fosc/2(2分頻,,即6倍于傳統(tǒng)速度)
#define EADCI 0x10 //使能ADC中斷位
#define ESPI 0x08 //使能SPI中斷位
#define ELVDI 0x04 //使能LVD中斷位
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr P0 = 0x80; //I/O端口0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - - - - P0.3 P0.2 P0.1 P0.0
//初始值=xxxx,1111 x x x x 1 1 1 1
sbit P03 = P0^3; //I/O口P0.3
sbit P02 = P0^2; //I/O口P0.2
sbit P01 = P0^1; //I/O口P0.1
sbit P00 = P0^0; //I/O口P0.0
/////////////////////////////////
sfr P1 = 0x90; //I/O端口0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0
//初始值=1111,1111 1 1 1 1 1 1 1 1
sbit P17 = P1^7; //I/O口P1.7
sbit P16 = P1^6; //I/O口P1.6
sbit P15 = P1^5; //I/O口P1.5
sbit P14 = P1^4; //I/O口P1.4
sbit P13 = P1^3; //I/O口P1.3
sbit P12 = P1^2; //I/O口P1.2
sbit P11 = P1^1; //I/O口P1.1
sbit P10 = P1^0; //I/O口P1.0
sbit ADCIN7 = P1^7; //ADC通道7的模擬信號(hào)輸入腳
sbit ADCIN6 = P1^6; //ADC通道6的模擬信號(hào)輸入腳
sbit ADCIN5 = P1^5; //ADC通道5的模擬信號(hào)輸入腳
sbit ADCIN4 = P1^4; //ADC通道4的模擬信號(hào)輸入腳
sbit ADCIN3 = P1^3; //ADC通道3的模擬信號(hào)輸入腳
sbit ADCIN2 = P1^2; //ADC通道2的模擬信號(hào)輸入腳
sbit ADCIN1 = P1^1; //ADC通道1的模擬信號(hào)輸入腳
sbit ADCIN0 = P1^0; //ADC通道0的模擬信號(hào)輸入腳
sbit SPISCLK = P1^7; //SPI總線的時(shí)鐘腳
sbit SPIMISO = P1^6; //SPI總線的主出從入腳
sbit SPIMOSI = P1^5; //SPI總線的主入從出腳
sbit SPISS = P1^4; //SPI總線的從機(jī)選擇腳
sbit T1CLKO = P1^1; //定時(shí)器1時(shí)鐘溢出脈沖輸出腳
sbit T0CLKO = P1^0; //定時(shí)器0時(shí)鐘溢出脈沖輸出腳
/////////////////////////////////
sfr P2 = 0xa0; //I/O端口2 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
//初始值=1111,1111 1 1 1 1 1 1 1 1
sbit P27 = P2^7; //I/O口P2.7
sbit P26 = P2^6; //I/O口P2.6
sbit P25 = P2^5; //I/O口P2.5
sbit P24 = P2^4; //I/O口P2.4
sbit P23 = P2^3; //I/O口P2.3
sbit P22 = P2^2; //I/O口P2.2
sbit P21 = P2^1; //I/O口P2.1
sbit P20 = P2^0; //I/O口P2.0
sbit CEX3 = P2^4; //比較/捕獲/PWM3外部引腳
sbit CEX2 = P2^0; //比較/捕獲/PWM2外部引腳
/////////////////////////////////
sfr P3 = 0xb0; //I/O端口3 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 P3.7 - P3.5 P3.4 P3.3 P3.2 P3.1 P3.0
//初始值=1x11,1111 1 x 1 1 1 1 1 1
sbit P37 = P3^7; //I/O口P3.7
sbit P35 = P3^5; //I/O口P3.5
sbit P34 = P3^4; //I/O口P3.4
sbit P33 = P3^3; //I/O口P3.3
sbit P32 = P3^2; //I/O口P3.2
sbit P31 = P3^1; //I/O口P3.1
sbit P30 = P3^0; //I/O口P3.0
sbit RXD = P3^0; //串口1的數(shù)據(jù)接收口
sbit TXD = P3^1; //串口1的數(shù)據(jù)發(fā)送口
sbit INT0 = P3^2; //外部中斷0的信號(hào)輸入口
sbit INT1 = P3^3; //外部中斷1的信號(hào)輸出口
sbit T0 = P3^4; //定時(shí)器0的外部信號(hào)輸入口
sbit T1 = P3^5; //定時(shí)器1的外部信號(hào)輸入口
sbit CEX0 = P3^7; //比較/捕獲/PWM0外部引腳
sbit CEX1 = P3^5; //比較/捕獲/PWM1外部引腳
sbit ECI = P3^4; //比較/捕獲/PWM模塊的外部時(shí)鐘輸入腳(最大值為Fosc/2)
/////////////////////////////////
sfr P1M0 = 0x91; //I/O口1模式控制器1 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初/始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr P1M1 = 0x92; //I/O口1模式控制器0 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr P0M0 = 0x93; //I/O口0模式控制器1 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -