2019-07-15 15:52发布
小麦地 发表于 2015-7-24 09:15 建议你把你的程序还是拿出来看看,哪里有问题可以指出来 让别人帮你看看 但是如果让别人直接给程序是不是。。。
最多设置5个标签!
void GO();
void BACK();
void TURNR();
void TURNL();
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR|=BIT6;
P2DIR|=BIT5+BIT4+BIT3;
P1DIR|=BIT0+BIT6;
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
UCA0CTL1=UCSSEL_2;
P1SEL|=BIT1+BIT2;
P1SEL2|=BIT1+BIT2;
UCA0BR0=104;
UCA0BR1=0x00;
UCA0MCTL=UCBRS1+UCBRS0;
UCA0CTL1&=~UCSWRST;
IE2|=UCA0RXIE;
__bis_SR_register(LPM3_bits+GIE);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR()
{
if(UCA0RXBUF=='g')
{
GO();
}
if(UCA0RXBUF=='b')
{
BACK();
}
if(UCA0RXBUF=='r')
{
TURNR();
}
if(UCA0RXBUF=='l')
{
TURNL();
}
}
void GO()
{
P1OUT|=BIT6;
P2OUT&=~BIT5;
P2OUT|=BIT4;
P2OUT&=~BIT3;
}
void BACK()
{
P1OUT&=~BIT6;
P2OUT|=BIT5;
P2OUT&=~BIT4;
P2OUT|=BIT3;
}
void TURNR()
{
P1OUT|=BIT6;//左侧电机前进右侧电机后退;
P2OUT&=~BIT5;
P2OUT&=~BIT4;
P2OUT|=BIT3;
}
void TURNL()
{
P1OUT&=~BIT6;
P2OUT|=BIT5;
P2OUT|=BIT4;
P2OUT&=~BIT3;
}
#include"msp430G2553.h"
void GO();
void BACK();
void TURNR();
void TURNL();
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR|=BIT6;
P2DIR|=BIT5+BIT4+BIT3;
P1DIR|=BIT0+BIT6;
BCSCTL1=CALBC1_1MHZ;
DCOCTL=CALDCO_1MHZ;
UCA0CTL1=UCSSEL_2;
P1SEL|=BIT1+BIT2;
P1SEL2|=BIT1+BIT2;
UCA0BR0=104;
UCA0BR1=0x00;
UCA0MCTL=UCBRS1+UCBRS0;
UCA0CTL1&=~UCSWRST;
IE2|=UCA0RXIE;
//__bis_SR_register(LPM3_bits+GIE);
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR()
{
if(UCA0RXBUF=='g')
{
GO();
}
if(UCA0RXBUF=='b')
{
BACK();
}
if(UCA0RXBUF=='r')
{
TURNR();
}
if(UCA0RXBUF=='l')
{
TURNL();
}
}
void GO()
{
P1OUT|=BIT6;
P2OUT&=~BIT5;
P2OUT|=BIT4;
P2OUT&=~BIT3;
}
void BACK()
{
P1OUT&=~BIT6;
P2OUT|=BIT5;
P2OUT&=~BIT4;
P2OUT|=BIT3;
}
void TURNR()
{
P1OUT|=BIT6;//左侧电机前进右侧电机后退;
P2OUT&=~BIT5;
P2OUT&=~BIT4;
P2OUT|=BIT3;
}
void TURNL()
{
P1OUT&=~BIT6;
P2OUT|=BIT5;
P2OUT|=BIT4;
P2OUT&=~BIT3;
}
帮我看看吧 写的太渣了
一周热门 更多>