请教关于51调速直流电机程序
2019-07-15 10:50发布
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
- <span style="line-height: 1.7; background-color: rgb(255, 255, 255);">这个程序一直抖,端口改不了,定死了</span>
复制代码- while(1)
- {
- P36=1;P37=1;
- ADC_CONTR = 0x88; //打开ADC电源 以及启动模数转换
- while(ADC_CONTR!=0x90); //开着ADC电源,判断是否转换完成
- Adc = ADC_RES;
- i=Adc;
- ADC_CONTR = 0x80;
- Delay30us(1);
- if(i<=0x0f){op=0;oy=d;}
- else if(i<=0x1f){op=d-550;oy=d-1;}
- else if(i<=0x2f){op=d-500;oy=d-2;}
- else if(i<=0x3f){op=d-450;oy=d-3;}
- else if(i<=0x4f){op=d-400;oy=d-4;}
- else if(i<=0x5f){op=d-350;oy=d-5;}
- else if(i<=0x6f){op=d-300;oy=d-7;}
- else if(i<=0x7f){op=d-250;oy=d-9;}
- else if(i<=0x9f){op=d-200;oy=d-12;}
- else if(i<=0xaf){op=d-150;oy=d-20;}
- else if(i<=0xbf){op=d-100;oy=d-27;}
- else if(i<=0xcf){op=d-50;oy=d-31;}
- else if(i<=0xdf){op=d-0;oy=d-38;}
- else {op=d;oy=1;}
- Delay30us(1);
- P36=0;P37=1;
- Delay30us(op);
- }
复制代码
一周热门 更多>