|
<><FONT color=#2b91d5 size=4><STRONG>1.代码:</STRONG></FONT></P><P><FONT color=#2b91d5 size=4>#include <hidef.h> /* common defines and macros */<BR>#include <mc9s12dg128.h> /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"</FONT></P><P><FONT color=#2b91d5 size=4>void main()<BR>{ </FONT></P><P><FONT color=#2b91d5 size=4> DDRA=0x00;//PORTA口为输入<BR> DDRB=0xFF;//PORTB口为输出<BR> PUCR=0x02; //PORTA口为上拉<BR> while(1)<BR> { <BR> PORTB=PORTA; //将PORTA口的输入值赋予PORTB口<BR> } </FONT></P><P><FONT color=#2b91d5 size=4>}</FONT></P><P><FONT color=#2b91d5 size=4><BR> </P></FONT><P><FONT color=#2b91d5 size=4><STRONG>2.功能:</STRONG></FONT></P><P><FONT color=#2b91d5 size=4>PORTA口输入决定PORTB口输出,可观察PORTB的小灯亮灭判断输入的是高电平还是低电平(PORTB口LED亮为低,灭为高,因为PORTB口的LED是上拉的,PORTA口设置为上拉是为了防干扰)</FONT></P><P><STRONG><FONT color=#2b91d5 size=4></FONT></STRONG> </P> |
|