>直接用</P><P>PORTB_BIT6=1或者0,</P><P>PORTB_BIT7=1或者0,</P><P>进行高低电平输出即可,上啦电阻可以这样设置:PUCR_PUPBE=1;</P><P>把delay(20);改为delay(500);延时要足够,太小了看不出来!</P>
>你可以试试这段程序,直接拷贝到你的MAIN.C文件中:</P><P>#include <hidef.h> /* common defines and macros */<BR>#include <mc9s12dg128.h> /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"</P><P>void delayms(int ms)<BR>{ <BR> int ii,jj;<BR> if (ms<1) ms=1;<BR> for(ii=0;ii<ms;ii++)<BR> for(jj=0;jj<1335;jj++); //16MHz--1ms <BR> } </P><P>void main(void) {<BR> /* put your own code here */<BR> unsigned char LedCnt=0;<BR> <BR> DDRB=0xFF;<BR> PUCR_PUPBE=1;<BR> <BR> EnableInterrupts;</P><P> for(;;) { <BR> <BR> LedCnt=(LedCnt>0XFE?0:++LedCnt);<BR> delayms(800); //修改延时以修改数据发送频率<BR> <BR> //低电平灯亮用这句 <BR> PORTB=~LedCnt;<BR> <BR> //高电平灯亮用这句<BR> //PORTB=LedCnt; <BR> <BR> } /* wait forever */<BR> /* please make sure that you never leave this function */<BR>}</P>| 欢迎光临 智能车制作 (http://www.znczz.com/) | Powered by Discuz! X3.2 |