实时记录MSP430编程问题
问题解决了:单片机坏了!!!内部的LISTEN估计被连上了,这块单片机只能用来做为发送端了。
另外,今日还遇到了中断子程序不作用的情况,网上各种寻找后发现程序中缺少 _EINT();导致无法运行中断程序,奇怪的是TI给的示范程序里面都没有_EINT(),我猜想是因为IAR版本或者所用调试程序不同的原因吧。
现在两块单片机已经能够进行简单的单工通信了,明天再来完善程序。
即:UCA1RXBUF = UCA1TXBUF
附上问题程序:
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
Init_Keypad();
Init_LCD();
write_command(0x3f); //打开显示
clear_LCD();
P5SEL = 0xC0; // P5.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL__ACLK; // ACLK
UCA1BR0 = 0x0D; // 2400
UCA1BR1 = 0; //
UCA1MCTL |= UCBRS_6 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE + UCTXIE; // Enable USCI_A0 RX,TX interrupt
while(1)
{
Key_Event(); //读取键值
if(key_Flag == 1)
{
key_Flag = 0;
UCA1TXBUF=key_val;
display_16_8((uchar *)&LCD_16_8[UCA1RXBUF][0],2,lie+72);//for debugger
display_16_8((uchar *)&LCD_16_8[UCA1RXBUF][0],4,lie+72);//for debugger
}
}
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
display_16_8((uchar *)&LCD_16_8[UCA1RXBUF][0],4,lie+72); // TX -> RXed character
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}
成功的程序:
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
Init_Keypad();
Init_LCD();
write_command(0x3f); //打开显示
clear_LCD();
P5SEL = 0xC0; // P5.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL__ACLK; // ACLK
UCA1BR0 = 0x0D; // 2400
UCA1BR1 = 0; //
UCA1MCTL |= UCBRS_6 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE + UCTXIE; // Enable USCI_A0 RX,TX interrupt
_EINT();
while(1)
{
Key_Event(); //读取键值
if(key_Flag == 1)
{
key_Flag = 0;
UCA1TXBUF=key_val;
}
}
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(UCA1IV)
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
if((UCA1RXBUF>=0)&&(UCA1RXBUF<10))
display_16_8((uchar *)&LCD_16_8[UCA1RXBUF][0],4,lie+72); // TX -> RXed character
break;
case 4:
if((UCA1TXBUF>=0)&&(UCA1TXBUF<10))
display_16_8((uchar *)&LCD_16_8[UCA1TXBUF][0],6,lie+72);
break; // Vector 4 - TXIFG
default: break;
}
}
实时记录MSP430编程问 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)