專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計實例 >> 瀏覽文章

關(guān)于SST89V58RD2的P4口的使用

作者:佚名   來源:本站原創(chuàng)   點擊數(shù):  更新時間:2010年09月14日   【字體:

感謝一下帖子

http://hi.baidu.com/ghy198607/blog/item/d9ae0063dbcc2dd6e6113a17.html

http://hi.baidu.com/baifei_110/blog/item/58086af1e9d9d9c47831aa5b.html

http://www.daxia.com/bibis/moredata30_1242625_86532.shtml

因為P4是無法位尋址的,這跟P0-P3不同,但是datasheet得sfr一節(jié)講到P4 is similar to P0-P3!

而且P4的度操作有bug!

正確操作如下:

sfr P4 = 0xa5;

#define SetBit(Value,Bit)  Value |= (0x01<<Bit)     //Bit(0~7)
#define ClrBit(Value,Bit)  Value &= (~(0x01<<Bit))
用這種方式去做位操作。

比如

//4^0
#define CS_0         ClrBit(P4,0)
#define CS_1         SetBit(P4,0)   
//4^1
#define PR_0          ClrBit(P4,1)
#define PR_1          SetBit(P4,1)   

一下方式讀引腳:

首先將整個程序配置為。╯mall)模式,
然后定義xdata空間的相關(guān)變量,如下:
uchar xdata temp;   
uchar xdata result;
temp=0x08;
result=P4&temp;
if((result==0x08)
{
.......
}

關(guān)閉窗口

相關(guān)文章