標題:
單片機地址傳遞的函數調用實驗
[打印本頁]
作者:
liuda
時間:
2015-1-21 23:11
標題:
單片機地址傳遞的函數調用實驗
是用51hei單片機開發(fā)板 電路圖詳見:
http://www.torrancerestoration.com/f/51hei-5.pdf
的數碼管部分, 用2個74hc573 鎖存,p0口作為數據口 ,p3.6和p3.7分別是段和位的鎖存端口.P2口上面是按鍵
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar code SEG7[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
sbit D=P3^6;
sbit V=P3^7;
sbit P2_4=P2^4;
//==============
void swap(uchar*x,uchar*y);
//===================
void delay(uint k)
{
uint i,j;
for(i=0;i<k;i++){
for(j=0;j<121;j++)
{;}}
}
//==================
void main(void)
{
uchar i;
uchar a=3,b=8;
uchar *pt1,*pt2;
pt1=&a;
pt2=&b;
while(1)
{
if(!P2_4)swap(pt1,pt2);
for(i=0;i<100;i++)
{D=1;P0=SEG7[a];D=0;P0=0xff;V=1;P0=0xfe;V=0;delay(5);
D=1;P0=SEG7[b];D=0;P0=0xff;V=1;P0=0xfd;V=0;delay(5);}
}
}
//================
void swap(uchar*x,uchar*y)
{
uchar t;
t=*x;
*x=*y;
*y=t;
}
復制代碼
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1