![手創(chuàng)科技技術(shù)匯集二程序初始化說明書_第1頁](http://file4.renrendoc.com/view/d51dd511e9715e3cbfa303c34f1e087a/d51dd511e9715e3cbfa303c34f1e087a1.gif)
![手創(chuàng)科技技術(shù)匯集二程序初始化說明書_第2頁](http://file4.renrendoc.com/view/d51dd511e9715e3cbfa303c34f1e087a/d51dd511e9715e3cbfa303c34f1e087a2.gif)
![手創(chuàng)科技技術(shù)匯集二程序初始化說明書_第3頁](http://file4.renrendoc.com/view/d51dd511e9715e3cbfa303c34f1e087a/d51dd511e9715e3cbfa303c34f1e087a3.gif)
![手創(chuàng)科技技術(shù)匯集二程序初始化說明書_第4頁](http://file4.renrendoc.com/view/d51dd511e9715e3cbfa303c34f1e087a/d51dd511e9715e3cbfa303c34f1e087a4.gif)
![手創(chuàng)科技技術(shù)匯集二程序初始化說明書_第5頁](http://file4.renrendoc.com/view/d51dd511e9715e3cbfa303c34f1e087a/d51dd511e9715e3cbfa303c34f1e087a5.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、手創(chuàng)科技技術(shù)資料匯集(一)手創(chuàng)科技擁有強(qiáng)大團(tuán)隊(duì)陣容,其中有多個(gè)成員曾參加飛思智能小車競賽并獲得一等獎(jiǎng)、華南賽區(qū)一等獎(jiǎng)等,參加過機(jī)械創(chuàng)新設(shè)計(jì)大賽取得省一等獎(jiǎng),同時(shí)有隊(duì)員獲得國家專利。技術(shù)實(shí)力雄厚,愿與各位參賽選手交流比賽心得,廣交朋友,追求一起進(jìn)步。永無止境。(手創(chuàng)科技淘寶店: HYPERLINK http:/s/ http:/s/)此資料匯集的部分程序初始化模塊:MC9S12XS128 系列例程-0/*/手創(chuàng)科技鼎力的技術(shù)支持。包括硬件和的支持,歡迎朋友們支持。并祝愿參賽選手們?nèi)〉煤贸煽?。淘寶店?HYPERLINK http:/s/ http:/s/Code Warrior 4.7: MC9
2、S12XS128Crystal: 16.000Mhz busclock:16.000MHz pllclock:32.000MHz=*/i nclude i nclude i nclude /* common defines and macros */#pragma LINK_INFO DERIVATIVE mc9s12xs128 byte u8_RCV_Ch=0 xff;/=中斷函數(shù)=#pragma CODE_SEG NON_BEDvoiderrupt 66 PIT0errupt(void)T;/ chesudu 需要定義的量PITTF_PTF0=1;T=0X0000;#pragma CODE
3、_SEG DEFAULTstatic void SCI_Init(void)SCI0CR2=0 x2c; /enable Receive Fullerrupt,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0
4、DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when not emptyvoid putstr(char ch)unsigned char ptr=0; while(chptr)uart_phar(unsigned char)chptr+);unsigned char uart_getkey(void)byte res=0; while(!(SCI0SR1&0 x80) ; return (SCI0DRL);/keep waiting when not empty/sic void Port
5、_Init(void)DDRB = 0 xff;/LEDPTB0-7,PORTB= 0 xff;/LEDs on/ PLL 初始化子程序void setbusclock(void)CLKSEL=0X00;BUS Clock=16M/disengage PLL to system/turn on PLLPLLCTL_PLLON=1; SYNR=1; REFDV=1;_asm(nop);_asm(nop);/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);/when pll is steady ,t
6、hen use it;/engage PLL to system;CLKSEL_PLLSEL =1;/sic void_Init(void)/SB,B for ch2367/SA,A for ch0145PRCLK = 0X55; SCLA = 0 x02;clock=clockA/4=125KHz;SCLB = 0X02;/clockA,CLK B 32 分頻:500khz/ 對 clock SA 進(jìn)行 2*SCLA=4分頻; /clk SB=clk B/(2*sclb)=125KHZ/1T1 = 0; CAE_CAE1=0; POL_PPOL1=0; PER1 =125;DTY1 =100
7、;CLK_PCLK1 = 1;E_E1 = 0;/void Init_Dev(void)setbusclock(); Port_Init(); SCI_Init();_Init();/void Beep(void)word tmper=125,tmdty=100;tmpWMPER1;tmdty=E_DTY1;E1 = 1;PER1 =125;DTY1 =100;Dly_ms(40);PER1 =tmper; DTY1 =tmdty;E_E1 = 0;#pragma CODE_SEG NEAR_SEG NON_BEDvoiderrupt 20 SCI0_ISR(void)SCI0CR2_RIE=
8、0;/此處為串口中斷需要處理的事情uart_phar(u8_RCV_Ch=uart_getkey();/PORTA_PA0=PORTA_PA0; PORTB_PB7=PORTB_PB7;switch(u8_RCV_Ch)case u:u8_RCV_Ch=0 xff;E_E1 = 1;/開啟/增大頻率0 波形輸出if(PER115)PER1-=5;break; case d:u8_RCV_Ch=0 xff;E_E1 = 1;if(PER1DTY1=/減小頻率if(PER1+10)/減小占空比PER1*4/5;/20%break; case l:u8_RCV_Ch=0 xff;E_E1 = 1;i
9、f(DTY1DTY1+;PER1)/增大占空比break; case r:u8_RCV_Ch=0 xff;E_E1 = 1;if(DTY1PER1)/減小占空比DTY1-;break; default:break;/switch(u8_RCV_Ch)/Beep();SCI0CR2_RIE = 1;/=main()=#pragma CODE_SEG DEFAULT void main(void)chartxtbuf16=;Init_Dev(); PORTB=0 x00;Dly_ms(1000); PORTB=0 xFF;Enableerrupts; for(;)Dly_ms(500);/0POR
10、TB_PB0=PORTB_PB0;/for(;) /mainMC9S12XS128 系列例程-RTI 0*/i nclude i nclude i nclude #pragma LINK_INFO DERIVATIVE mc9s12xs128volatile dwordt=0;/sic void Port_Init(void)DDRA = 0 xff;PORTA= 0 x00;DDRB = 0 xff;/LEDPTB0-7,PORTB= 0 xff;/LEDs off/sic void SCI_Init(void)SCI0CR2=0 x2c; /enable Receive Fullerrup
11、t,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when
12、 not emptyvoid putstr(char ch)unsigned char ptr=0; while(chptr)uart_phar(unsigned char)chptr+);/ setup of the RTIerrupt frequencysic void RTI_Init(void)RTICTL=0 x77;/CRG=0X80;/8x216 =32,75ms,30.5175Hz/enable RTIerruptCRG=0X80;/enable RTIerrupt/ PLL 初始化子程序void setbusclock(void)CLKSEL=0X00;BUS Clock=1
13、6M/disengage PLL to systemPLLCTL_PLLON=1;/turn on PLLSYNR=1;REFDV=1;/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;_asm(nop);_asm(nop); while(!(CRG/BUS CLOCK=16M_LOCK=1);/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/#pragma CODE_SEG DEFAULT void Init_Dev(void)setbusclock(); Port
14、_Init(); SCI_Init(); RTI_Init();/=main()=#pragma CODE_SEG DEFAULT void main(void)char bytewordtxtbuf66=; u8_mes=0;u16_sec=0,u16_ms=0;Init_Dev(); PORTB=0 x00;putstr(nLongQiu s.&t. Co. putstr(nDLY_ms(1000); PORTB=0 xFF;Enableerrupts; for(;).););/時(shí)鐘計(jì)時(shí)器u1t*131/4;/理論值為 32.75ms,時(shí)間計(jì)算部分u16_ms=u16_sec%1000;
15、u16_sec=u16_sec/1000;sprf(txtbuf,n%d:%02ds-%03dms ,u8_mes,u16_sec,u16_ms); putstr(txtbuf);if(u16_sec58)u8_mes+;t=0;/PORTB_PB0=PORTB_PB0; DLY_ms(50);/for(;) /maini nclude /* common defines and macros */i nclude i nclude /* derivative information */#pragma LINK_INFO DERIVATIVE mc9s12xs128#pragma CODE_
16、SEG DEFAULT/void setbusclock(void)CLKSEL=0X00; PLLCTL_PLLON=1; SYNR=1; REFDV=1;_asm(nop);_asm(nop);/disengage PLL to system/turn on PLL/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/ sic void SCI_Ini
17、t(void)SCI0CR2=0 x2c; /enable Receive Fullerrupt,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0S
18、R1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when not emptyvoid putstr(char ch)unsigned char ptr=0;while(chptr)uart_phar(unsigned char)chptr+);unsigned char uart_getkey(void)byte res=0; while(!(SCI0SR1&0 x80) ; return (SCI0DRL);/keep waiting when not empty/void AD_Init(void)ATD0CTL1=0 x00; ATD0CTL2=0
19、x40; ATD0CTL3=0 xa0;ATD0CTL4=0 x01;/7:1-外部觸發(fā),65:00-8 位精度,4:放電,3210:ch/外部觸發(fā), 中斷/右對齊無符號,每次轉(zhuǎn)換 4 個(gè)序列, No FIFO, Freeze 模式下繼續(xù)轉(zhuǎn)/765:采 樣 時(shí) 間為4個(gè)AD時(shí)鐘周期,ATDClock=BusClock*0.5/PRS+1ATD0CTL5=0 x30;/6:0 特殊通道,5:1 連續(xù)轉(zhuǎn)換,4:1 多通道輪流采樣ATD0DIEN=0 x00;/數(shù)字輸入/void Dly_ms(ii,jj;ms)if (ms1) ms=1; for(ii=0;iims;ii+)for(jj=0;jj
20、t);/修改延時(shí)以修改數(shù)據(jù)發(fā)送頻率/低電平燈亮用這句,注釋掉下面那句 PORTA_PA0=PORTA_PA0;t;/燈亮用這句,注釋掉上面那句t;fenwei=ReadATD(0) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD0:%d.%02dV,gewei,fenwei);putstr(txtbuf);fenwei=ReadATD(1) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nA
21、D1:%d.%02dV,gewei,fenwei); putstr(txtbuf);fenwei=ReadATD(2) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD2:%d.%02dV,gewei,fenwei); putstr(txtbuf);fenwei=ReadATD(3) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD3:%d.%02dV;,gewei,fenwei); pu
22、tstr(txtbuf);MC9S12XS128 系列例程-IOC0i nclude i nclude i nclude #pragma LINK_INFO DERIVATIVE mc9s12xs128/void setbusclock(void)CLKSEL=0X00; PLLCTL_PLLON=1; SYNR=1; REFDV=1;_asm(nop);_asm(nop);/disengage PLL to system/turn on PLL/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);
23、/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/sic void SCI_Init(void)SCI0CR2=0 x2c; /enable Receive Fullerrupt,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar
24、(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when not emptyvoid putstr(char ch)unsigned char ptr=0; while(chptr)uart_phar(unsigned char)chptr+);/sic void IOC_Init(void)PACTL=0X50;/PT732 16BIT,FALLing edge,NOTERRUP
25、TTCTL3=0 xc0;/c-輸入捕捉 7 任何沿有效,TCTL4=0 xc0;/40 表示 IC止, 1 表示上升沿, 2 表示下降沿, 3 表示任何沿TIE=0 x00;/每一位對應(yīng)相應(yīng)通道中斷允許,0 表示中斷TIOS =0 x00;/每一位對應(yīng)通道的: 0 輸入捕捉,1 輸出比較TCTL3_EDG7x=1;/c-輸入捕捉 7 任何沿有效,/void Dly_ms(ii,jj;ms)if (ms1) ms=1; for(ii=0;iims;ii+)for(jj=0;jjt);/修改延時(shí)以修改數(shù)據(jù)發(fā)送頻率/低電平燈亮用這句,注釋掉下面那句t;/燈亮用這句,注釋掉上面那句t;T;t999)
26、if(sprT=0;f(mystr,nIOC pulses:%dt);putstr(mystr);*/#include /* common defines and macros */#include /* derivative information */#pragma LINK_INFO DERIVATIVE mc9s12xs128void delayms(ii,jj;ms)if (ms1) ms=1; for(ii=0;iims;ii+)for(jj=0;jjt);/ 修改延時(shí)以修改數(shù)據(jù)發(fā)送頻率/低電平燈亮用這句,注釋掉下面那句t;/ 測試版系統(tǒng)板PORTA_PA0=PORTA_PA0;/
27、 測試龍丘最小系統(tǒng)板/PORTB_BIT7=PORTB_BIT7;/燈亮用這句,注釋掉上面那句t; /* wait forever */* please make suret you never leave this function */MC9S12XS128 系列例程-0/*手創(chuàng)科技鼎力的技術(shù)支持。包括硬件和的支持,歡迎朋友們支持。并祝愿參賽選手們?nèi)〉煤贸煽?。淘寶店?HYPERLINK http:/s/ http:/s/Code Warrior 4.7: MC9S12XS128Crystal: 16.000Mhz busclock:16.000MHz pllclock:32.000MHz
28、=*/i nclude i nclude i nclude /* common defines and macros */#pragma LINK_INFO DERIVATIVE mc9s12xs128 byte u8_RCV_Ch=0 xff;/=中斷函數(shù)=#pragma CODE_SEG NON_BEDvoiderrupt 66 PIT0errupt(void)T;/ chesudu 需要定義的量PITTF_PTF0=1;T=0X0000;#pragma CODE_SEG DEFAULTstatic void SCI_Init(void)SCI0CR2=0 x2c; /enable Rec
29、eive Fullerrupt,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/kee
30、p waiting when not emptyvoid putstr(char ch)unsigned char ptr=0; while(chptr)uart_phar(unsigned char)chptr+);unsigned char uart_getkey(void)byte res=0; while(!(SCI0SR1&0 x80) ; return (SCI0DRL);/keep waiting when not empty/sic void Port_Init(void)DDRB = 0 xff;/LEDPTB0-7,PORTB= 0 xff;/LEDs on/ PLL 初始
31、化子程序void setbusclock(void)CLKSEL=0X00;BUS Clock=16M/disengage PLL to system/turn on PLLPLLCTL_PLLON=1; SYNR=1; REFDV=1;_asm(nop);_asm(nop);/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/sic void_Init
32、(void)/SB,B for ch2367/SA,A for ch0145PRCLK = 0X55; SCLA = 0 x02;clock=clockA/4=125KHz;SCLB = 0X02;/clockA,CLK B 32 分頻:500khz/ 對 clock SA 進(jìn)行 2*SCLA=4分頻; /clk SB=clk B/(2*sclb)=125KHZ/1T1 = 0;CAE_CAE1=0;POL_PPOL1=0; PER1 =125;DTY1 =100;CLK_PCLK1 = 1;E_E1 = 0;/void Init_Dev(void)setbusclock(); Port_In
33、it(); SCI_Init();_Init();/void Beep(void)word tmper=125,tmdty=100; tmpWMPER1;tmdty=E_DTY1;E1 = 1;PER1 =125;DTY1 =100;Dly_ms(40);PER1 =tmper; DTY1 =tmdty;E_E1 = 0;#pragma CODE_SEG NEAR_SEG NON_BEDvoiderrupt 20 SCI0_ISR(void)SCI0CR2_RIE=0;/此處為串口中斷需要處理的事情uart_phar(u8_RCV_Ch=uart_getkey();/PORTA_PA0=POR
34、TA_PA0; PORTB_PB7=PORTB_PB7;switch(u8_RCV_Ch)case u:u8_RCV_Ch=0 xff;E_E1 = 1;/開啟/增大頻率0 波形輸出if(PER115)PER1-=5;break; case d:u8_RCV_Ch=0 xff;E_E1 = 1;if(PER1DTY1=/減小頻率if(PER1+10)/減小占空比PER1*4/5;/20%break; case l:u8_RCV_Ch=0 xff;E_E1 = 1;if(DTY1DTY1+;PER1)/增大占空比break; case r:u8_RCV_Ch=0 xff;E_E1 = 1;if(
35、DTY1PER1)/減小占空比DTY1-;break; default:break;/switch(u8_RCV_Ch)/Beep();SCI0CR2_RIE = 1;/=main()=#pragma CODE_SEG DEFAULT void main(void)chartxtbuf16=;Init_Dev(); PORTB=0 x00;Dly_ms(1000); PORTB=0 xFF;Enableerrupts; for(;)Dly_ms(500);/0PORTB_PB0=PORTB_PB0;/for(;) /mainMC9S12XS128 系列例程-RTI 0*/i nclude i
36、nclude i nclude #pragma LINK_INFO DERIVATIVE mc9s12xs128volatile dwordt=0;/sic void Port_Init(void)DDRA = 0 xff; PORTA= 0 x00;DDRB = 0 xff;/LEDPTB0-7,PORTB= 0 xff;/LEDs off/sic void SCI_Init(void)SCI0CR2=0 x2c; /enable Receive Fullerrupt,RX enable,Tx enableSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL
37、=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when not emptyvoid putstr(char ch)unsigned char ptr=0; while(chptr)u
38、art_phar(unsigned char)chptr+);/ setup of the RTIerrupt frequencysic void RTI_Init(void)RTICTL=0 x77;/CRG=0X80;/8x216 =32,75ms,30.5175Hz/enable RTIerruptCRG=0X80;/enable RTIerrupt/ PLL 初始化子程序void setbusclock(void)CLKSEL=0X00;BUS Clock=16M/disengage PLL to system/turn on PLLPLLCTL_PLLON=1; SYNR=1; RE
39、FDV=1;_asm(nop);_asm(nop);/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/#pragma CODE_SEG DEFAULT void Init_Dev(void)setbusclock(); Port_Init(); SCI_Init(); RTI_Init();/=main()=#pragma CODE_SEG DEFAU
40、LT void main(void)char bytewordtxtbuf66=; u8_mes=0;u16_sec=0,u16_ms=0;Init_Dev(); PORTB=0 x00;putstr(nLongQiu s.&t. Co.putstr(n.););DLY_ms(1000); PORTB=0 xFF;Enableerrupts; for(;)/時(shí)鐘計(jì)時(shí)器u1t*131/4;/理論值為 32.75ms,時(shí)間計(jì)算部分u16_ms=u16_sec%1000; u16_sec=u16_sec/1000;sprf(txtbuf,n%d:%02ds-%03dms ,u8_mes,u16_se
41、c,u16_ms); putstr(txtbuf);if(u16_sec58)u8_mes+;t=0;/PORTB_PB0=PORTB_PB0; DLY_ms(50);/for(;) /maini nclude /* common defines and macros */i nclude i nclude /* derivative information */#pragma LINK_INFO DERIVATIVE mc9s12xs128#pragma CODE_SEG DEFAULT/void setbusclock(void)CLKSEL=0X00; PLLCTL_PLLON=1; S
42、YNR=1; REFDV=1;_asm(nop);_asm(nop);/disengage PLL to system/turn on PLL/pllclock=2*osc*(1+SYNR)/(1+REFDV)=32MHz;/BUS CLOCK=16Mwhile(!(CRG_LOCK=1);/when pll is steady ,then use it;/engage PLL to system;CLKSEL_PLLSEL =1;/sic void SCI_Init(void)SCI0CR2=0 x2c; /enable Receive Fullerrupt,RX enable,Tx ena
43、bleSCI0BDH=0 x00; /busclk8MHz,19200bps,SCI0BDL=0 x1a SCI0BDL=0 x68; /SCI0BDL=busclk/(16*SCI0BDL)/busclk 16MHz, 9600bps,SCI0BDL=0 x68void uart_phar(unsigned char ch)if (ch = n)while(!(SCI0SR1&0 x80) ; SCI0DRL= 0 x0d;return;while(!(SCI0SR1&0 x80) ; SCI0DRL=ch;/outpR/keep waiting when not emptyvoid put
44、str(char ch)unsigned char ptr=0; while(chptr)uart_phar(unsigned char)chptr+);unsigned char uart_getkey(void)byte res=0; while(!(SCI0SR1&0 x80) ; return (SCI0DRL);/keep waiting when not empty/void AD_Init(void)ATD0CTL1=0 x00; ATD0CTL2=0 x40; ATD0CTL3=0 xa0;ATD0CTL4=0 x01;/7:1-外部觸發(fā),65:00-8 位精度,4:放電,32
45、10:ch/外部觸發(fā), 中斷/右對齊無符號,每次轉(zhuǎn)換 4 個(gè)序列, No FIFO, Freeze 模式下繼續(xù)轉(zhuǎn)/765:采 樣 時(shí) 間 為4個(gè)AD時(shí) 鐘 周期,ATDClock=BusClock*0.5/PRS+1ATD0CTL5=0 x30;ATD0DIEN=0 x00;/6:0 特殊通道,5:1 連續(xù)轉(zhuǎn)換 ,4:1 多通道輪流采樣/數(shù)字輸入/void Dly_ms(ii,jj;ms)if (ms1) ms=1; for(ii=0;iims;ii+)for(jj=0;jjt);/修改延時(shí)以修改數(shù)據(jù)發(fā)送頻率/低電平燈亮用這句,注釋掉下面那句 PORTA_PA0=PORTA_PA0;t;/燈亮
46、用這句,注釋掉上面那句t;fenwei=ReadATD(0) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD0:%d.%02dV,gewei,fenwei);putstr(txtbuf);fenwei=ReadATD(1) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD1:%d.%02dV,gewei,fenwei); putstr(txtbuf);fenwei=ReadATD(2) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD2:%d.%02dV,gewei,fenwei);putstr(txtbuf);fenwei=ReadATD(3) *100/51;/參考電壓 5V, 500/255 gewei=fenwei/100;fenwei=fenwei%100;sprf(txtbuf,nAD3:%d.%02dV;,gewei,fenwei); putstr(txtbuf);MC9S12XS128 系列例程-IOC0i nclude i nclude i n
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度輔導(dǎo)班家長學(xué)生綜合素質(zhì)評價(jià)體系合同
- 二零二五年度食堂工作人員聘用合同(含食品安全管理)
- 《黑刺粉虱防治》課件
- 《旅館設(shè)計(jì)要求》課件
- 《牛羊病防治》課件
- 《狼羊作文評講》課件
- 2025年環(huán)保管家技術(shù)服務(wù)合同-企業(yè)綠色生產(chǎn)咨詢與培訓(xùn)協(xié)議
- 《紅豆杉泡沫劑》課件
- 四年級上美術(shù)課件-生長的植物浙美版
- 人力資源管理專業(yè)概述
- 門窗安裝施工安全管理方案
- 婦科手術(shù)麻醉
- 2024年安徽省高校分類對口招生考試數(shù)學(xué)試卷真題
- ISO45001管理體系培訓(xùn)課件
- 動畫課件教學(xué)教學(xué)課件
- 小學(xué)生心理健康講座5
- 綿陽市高中2022級(2025屆)高三第一次診斷性考試(一診)數(shù)學(xué)試卷(含答案逐題解析)
- 貴州省房屋建筑和市政工程標(biāo)準(zhǔn)監(jiān)理電子招標(biāo)文件(2023年版)
- 高級職業(yè)培訓(xùn)師(三級)職業(yè)資格鑒定考試題及答案
- 小學(xué)英語800詞分類(默寫用)
- 真實(shí)世界研究指南 2018
評論
0/150
提交評論