?? stcmcu+
字號(hào):
/////////////////////////////////
sfr TH1 = 0x8d; //定時(shí)器1的高8位計(jì)數(shù)值 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr SCON = 0x98; //串口控制寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 SM0/FE SM1 SM2 REN TB8 RB8 TI Ri
//初始值=0000,0000 0 0 0 0 0 0 0 0
sbit FE = SCON^7; //幀錯(cuò)誤檢測(cè)位,當(dāng)串口模塊在接收數(shù)據(jù)時(shí)沒有檢測(cè)到正確的停止位時(shí),FE被硬件置1,需要由軟件來(lái)清0(當(dāng)SMOD0為1時(shí),FE有效)
sbit SM0 = SCON^7; //串口模式設(shè)置位
sbit SM1 = SCON^6; //SM0/SM1=0/0:移位寄存器 0/1:8位可變波特率 1/0:9位固定波特率 1/1:9位可變波特率
sbit SM2 = SCON^5; //自動(dòng)地址識(shí)別使能位
sbit REN = SCON^4; //使能串口接收模塊
sbit TB8 = SCON^3; //發(fā)送的第9位數(shù)據(jù)
sbit RB8 = SCON^2; //接收的第9位數(shù)據(jù)
sbit TI = SCON^1; //發(fā)送完成中斷標(biāo)志
sbit RI = SCON^0; //接收完成中斷標(biāo)志
/////////////////////////////////
sfr SBUF = 0x99; //串口接收/發(fā)送數(shù)據(jù) Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=xxxx,xxxx x x x x x x x x
/////////////////////////////////
sfr SADDR = 0xa9; //串口設(shè)備從地址寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr SADEN = 0xb9; //串口設(shè)備從地址屏蔽位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr BRT = 0x9c; //獨(dú)立波特率發(fā)生器重載值Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr ADC_CONTR = 0xbc; //ADC控制寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 ADC_POWER SPEED1 SPEED0 ADC_FLAG ADC_START CHS2 CHS1 CHS0
//初始值=0000,0000 0 0 0 0 0 0 0 0
#define ADC_POWER 0x80 //ADC模塊電源控制位
#define ADC_SPEEDLL 0x00 //每次轉(zhuǎn)換需要540個(gè)時(shí)鐘周期
#define ADC_SPEEDL 0x20 //每次轉(zhuǎn)換需要360個(gè)時(shí)鐘周期
#define ADC_SPEEDH 0x40 //每次轉(zhuǎn)換需要180個(gè)時(shí)鐘周期
#define ADC_SPEEDHH 0x60 //每次轉(zhuǎn)換需要90個(gè)時(shí)鐘周期
#define ADC_FLAG 0x10 //ADC轉(zhuǎn)換完成標(biāo)志
#define ADC_START 0x08 //ADC開始轉(zhuǎn)換控制位
#define ADC_CHS2 0x04 //ADC通道選擇位2
#define ADC_CHS1 0x02 //ADC通道選擇位1
#define ADC_CHS0 0x01 //ADC通道選擇位0
/////////////////////////////////
sfr ADC_RES = 0xbd; //ADC結(jié)果 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr IAP_DATA = 0xc2; //IAP數(shù)據(jù)寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=1111,1111 1 1 1 1 1 1 1 1
/////////////////////////////////
sfr IAP_ADDRH = 0xc3; //IAP地址高位寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr IAP_ADDRL = 0xc4; //IAP地址低位寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr IAP_CMD = 0xc5; //IAP命令寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=xxxx,xx00 x x x x x x 0 0
#define IAP_IDLE 0x00 //IAP待機(jī)命令
#define IAP_READ 0x01 //IAP讀字節(jié)數(shù)據(jù)命令
#define IAP_PROGRAM 0x02 //IAP字節(jié)編程命令
#define IAP_ERASE 0x03 //IAP扇區(qū)擦除命令(每扇區(qū)512字節(jié)))
/////////////////////////////////
sfr IAP_TRIG = 0xc6; //IAP命令觸發(fā)寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=xxxx,xxxx x x x x x x x x
#define IAP_TRIG0 0x5a //IAP功能觸發(fā)命令1
#define IAP_TRIG1 0xa5 //IAP功能觸發(fā)命令2
/////////////////////////////////
sfr IAP_CONTR = 0xc7; //IAP控制寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 IAPEN SWBS SWRST CMD_FAIL - WT2 WT1 WT0
//初始值=0000,0000 0 0 0 0 0 0 0 0
#define IAPEN 0x80 //IAP使能開關(guān)
#define SWBS 0x40 //軟啟動(dòng)選擇,0:從用戶AP啟動(dòng) 1:從ISP啟動(dòng)
#define SWRST 0x20 //觸發(fā)軟件復(fù)位
#define CMD_FAIL 0x10 //IAP命令失敗標(biāo)志
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sfr CCON = 0xd8; //PCA控制寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 CF CR - - - - CCF1 CCF0
//初始值=00xx,xx00 0 0 x x x x 0 0
sbit CF = CCON^7; //PCA計(jì)數(shù)器溢出標(biāo)志,當(dāng)PCA中斷使能時(shí)會(huì)觸發(fā)PCA中斷請(qǐng)求,需要用軟件清0
sbit CR = CCON^6; //PCA計(jì)數(shù)器啟動(dòng)控制位,寫"1"啟動(dòng)?xùn)|計(jì)數(shù)器
sbit CCF1 = CCON^1; //PCA模塊1中斷標(biāo)志,需要用軟件清0
sbit CCF0 = CCON^0; //PCA模塊0中斷標(biāo)志,需要用軟件清0
/////////////////////////////////
sfr CMOD = 0xd9; //PCA模式寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 CIDL - - - CPS2 CPS1 CPS0 ECF
//初始值=0xxx,0000 0 x x x 0 0 0 0
#define CIDL 0x80 //計(jì)時(shí)器陣列空閑控制,0:空閑模式下PCA繼續(xù)工作 1:空閑模式下PCA停止工作
#define PCACLK0 0x00 //Fosc/12
#define PCACLK1 0x02 //Fosc/2
#define PCACLK2 0x04 //定時(shí)器0的溢出率
#define PCACLK3 0x06 //ECI外部時(shí)鐘
#define PCACLK4 0x08 //Fosc/1
#define PCACLK5 0x0a //Fosc/4
#define PCACLK6 0x0c //Fosc/6
#define PCACLK7 0x0e //Fosc/8
#define ECF 0x01 //PCA計(jì)數(shù)器溢出中斷允許位
/////////////////////////////////
sfr CCAPM0 = 0xda; //PCA模塊0模式寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - ECOM0 CAPP0 CAPN0 MAT0 TOG0 PWM0 ECCF0
//初始值=x000,0000 x 0 0 0 0 0 0 0
#define PCA0_ECOM 0x40 //使能比較器0
#define PCA0_CAPP 0x20 //使能PCA模塊0的上升沿捕獲
#define PCA0_CAPN 0x10 //使能PCA模塊0的下降沿捕獲
#define PCA0_MAT 0x08 //匹配使能,當(dāng)PCA的計(jì)數(shù)值與模塊0設(shè)定的值相匹配時(shí),置CCON.CCF0
#define PCA0_TOG 0x04 //翻轉(zhuǎn)控制位,當(dāng)PCA的計(jì)數(shù)值與模塊0設(shè)定的值相匹配時(shí),翻轉(zhuǎn)CEX0的電平
#define PCA0_PWM 0x02 //脈寬調(diào)制模式,使能CEX0為脈寬調(diào)制輸出口
#define PCA0_ECCF 0x01 //使能CCF0中斷
/////////////////////////////////
sfr CCAPM1 = 0xdb; //PCA模塊1模式寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - ECOM1 CAPP1 CAPN1 MAT1 TOG1 PWM1 ECCF1
//初始值=x000,0000 x 0 0 0 0 0 0 0
#define PCA1_ECOM 0x40 //使能比較器1
#define PCA1_CAPP 0x20 //使能PCA模塊1的上升沿捕獲
#define PCA1_CAPN 0x10 //使能PCA模塊1的下降沿捕獲
#define PCA1_MAT 0x08 //匹配使能,當(dāng)PCA的計(jì)數(shù)值與模塊1設(shè)定的值相匹配時(shí),置CCON.CCF1
#define PCA1_TOG 0x04 //翻轉(zhuǎn)控制位,當(dāng)PCA的計(jì)數(shù)值與模塊1設(shè)定的值相匹配時(shí),翻轉(zhuǎn)CEX1的電平
#define PCA1_PWM 0x02 //脈寬調(diào)制模式,使能CEX1為脈寬調(diào)制輸出口
#define PCA1_ECCF 0x01 //使能CCF1中斷
/////////////////////////////////
//CCAPM0 - ECOM CAPP CAPN MAT TOG PWM CCF
// 00H 0 0 0 0 0 0 0 0 無(wú)操作,待機(jī)狀態(tài)
// 42H 0 1 0 0 0 0 1 0 8位PWM輸出,無(wú)中斷
// 63H 0 1 1 0 0 0 1 1 8位PWM輸出,產(chǎn)生CEX0上升沿中斷
// 53H 0 1 0 1 0 0 1 1 8位PWM輸出,產(chǎn)生CEX0下降沿中斷
// 73H 0 1 1 1 0 0 1 1 8位PWM輸出,產(chǎn)生CEX0跳變中斷
// 20H 0 x 1 0 0 0 0 0 16位捕獲模式,CEX0上升沿觸發(fā)捕獲
// 10H 0 x 0 1 0 0 0 0 16位捕獲模式,CEX0下降沿觸發(fā)捕獲
// 30H 0 x 1 1 0 0 0 0 16位捕獲模式,CEX0跳變觸發(fā)捕獲
// 48H 0 1 0 0 1 0 0 0 16位軟件定時(shí)器
// 4CH 0 1 0 0 1 1 0 0 16位高速脈沖輸出
/////////////////////////////////
sfr CL = 0xe9; //PCA計(jì)數(shù)器低8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr CH = 0xf9; //PCA計(jì)數(shù)器高8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr CCAP0L = 0xea; //PCA模塊0寄存器低8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr CCAP1L = 0xeb; //PCA模塊1寄存器低8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr CCAP0H = 0xfa; //PCA模塊0寄存器高8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr CCAP1H = 0xfb; //PCA模塊1寄存器高8位 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//初始值=0000,0000 0 0 0 0 0 0 0 0
/////////////////////////////////
sfr PCA_PWM0 = 0xf2; //PCA0模式PWM輔助寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - - - - - - EPC0H EPC0L
//初始值=xxxx,xx00 x x x x x x 0 0
/////////////////////////////////
sfr PCA_PWM1 = 0xf3; //PCA1模式PWM輔助寄存器 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
//位描述 - - - - - - EPC1H EPC1L
//初始值=xxxx,xx00 x x x x x x 0 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -