2011电子设计B题设计报告修改版

全国大学生电子设计竞赛

if(RoundGo) { count1++;

if(count1==40) {

PUL = ~PUL; count1 = 0; // 2*40*7.8125uS=625uS 3200r/2S } } }

//INT1

void INT1_ISR (void) interrupt 2 {

uchar i,step,fine; static uchar tempsum=0; if(Angel_Plus_B) { Angel ++; if(ReadyFlag) { DIR = LEFT; step = XDBuShu[180-Angel]; tempsum += step; fine = 37; } if(RoundGo && (Drection==LEFT) && (RoundCount == 10)) { RoundCount ++;} } else { Angel --; if(ReadyFlag) { DIR = RIGHT; step = XDBuShu[180-Angel]; tempsum += step; fine = 43; }

// if(RoundGo && (Drection==RIGHT)) {AngelMaxR = -Angel;} } if(BStartFlag) {

27

全国大学生电子设计竞赛

if(((AngelMax >0) && ((AngelMax-Angel)>13)) || ((AngelMax <0) && ((Angel-AngelMax)>13))) { RoundGo = 1; BStartFlag = 0; } } if(ReadyFlag) { if(tempsum>=fine) {step ++; tempsum -= fine;} for(i=0;i

//INT0

void INT0_ISR (void) interrupt 0 { Angel = 0; Drection ^= 1; if(RoundGo) RoundCount ++; } //

uchar ScanKey() {

uchar key; key = P2;

if(key & 0x04) return KEY1; if(key & 0x08) return KEY2; if(key & 0x10) return KEY3; if(key & 0x20) return KEY4; else return 0xff; }

28

全国大学生电子设计竞赛

void Delayms(unsigned int x) {

unsigned int i; while(x--) for(i=0; i<= 2200; i++); }

void Delay50us(unsigned int x) {

unsigned int i; while(x--){ for(i=0; i<= 110; i++);} }

void Delay1us(unsigned int x) {

unsigned int i; while(x--){ for(i=0; i<= 2; i++);} }

29

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4