日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當前位置:首頁 > 單片機 > 單片機
[導讀]#includetypedefunsignedcharuchar;typedefunsignedintuint;typedefunsignedlongulong;ucharcodebeatCode[8]={0xE,0xC,0xD,0x9,0xB,0x3,0x7,0x6};ulongbeats=0;ucharT0RH=0,T0RL=0;voidturnMotor(ulongangle){EA=0;b

#include

typedefunsignedcharuchar;

typedefunsignedintuint;

typedefunsignedlongulong;

ucharcodebeatCode[8]={

0xE,0xC,0xD,0x9,0xB,0x3,0x7,0x6

};

ulongbeats=0;

ucharT0RH=0,T0RL=0;

voidturnMotor(ulongangle){

EA=0;

beats=angle*4076/360;

EA=1;

}

voidsetTimer0(uintms){

ulongtmp;

tmp=11059326/12;

tmp=tmp*ms/1000;

tmp=65536-tmp;

tmp+=28;

T0RL=tmp;

T0RH=tmp>>8;

}

voidinterruptTimer0()interrupt1{

staticucharindex=0;

TH0=T0RH;

TL0=T0RL;

if(beats){

uchartmp=P1;

tmp&=0xF0;

tmp|=beatCode[index];

P1=tmp;

index=++index&0x07;

beats--;

}

else{

P1|=0x0F;

}

}

voidmain(){

EA=1;

TMOD=0x01;

setTimer0(2);

TH0=T0RH;

TL0=T0RL;

ET0=1;

TR0=1;

turnMotor(2*360+180);

while(1);

}

下面是使用庫函數(shù)循環(huán)左移實現(xiàn)的:


#include

#include

typedefunsignedcharuchar;

typedefunsignedintuint;

typedefunsignedlongulong;

ulongbeats=0;

ucharT0RH=0,T0RL=0;

voidturnMotor(ulongangle){

EA=0;

beats=angle*4076/360;

EA=1;

}

voidsetTimer0(uintms){

ulongtmp;

tmp=11059326/12;

tmp=tmp*ms/1000;

tmp=65536-tmp;

tmp+=28;

T0RL=tmp;

T0RH=tmp>>8;

}

voidinterruptTimer0()interrupt1{

staticucharbeatCode=0x33;

TH0=T0RH;

TL0=T0RL;

if(beats){

uchartmp=P1;

tmp&=0xF0;

beatCode=_crol_(beatCode,1);

tmp|=beatCode;

P1=tmp;

beats--;

}

else{

P1|=0x0F;

}

}

voidmain(){

EA=1;

TMOD=0x01;

setTimer0(2);

TH0=T0RH;

TL0=T0RL;

ET0=1;

TR0=1;

turnMotor(2*360+180);

while(1);

}


本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內容侵犯您的權益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關閉