共2条
1/1 1 跳转至页
430F149 【求助】430F149中的串口1问题
问
源程序:
//******************************************************************************
// MSP-FET430P140 Demo - USART1 UART 2400 Ultra-low Power Echo ISR, 32kHz ACLK
//
// Description; Echo a received character, RX ISR used. In the Mainloop UART1
// is made ready to receive one character with interrupt active. The Mainloop
// waits in LPM3. The UART1 ISR forces the Mainloop to exit LPM3 after
// receiving one character which echo's back the received character.
// ACLK = UCLK1 = LFXT1 = 32768, MCLK = SMCLK = DCO ~ 800k
// Baud rate divider with 32768hz XTAL 2400 = 32768Hz/2400 = 13.65 (000Dh)
// //*An external watch crystal is required on XIN XOUT for ACLK*//
//
// MSP430F149
// -----------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P3.6|----------->
// | | 2400 - 8N1
// | P3.7|<-----------
//
//
// M. Buccini
// Texas Instruments, Inc
// February 2002
// Built with IAR Embedded Workbench Version: 1.25A
//******************************************************************************
#include <MSP430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
UCTL1&=~SWRST;
UCTL1 = CHAR; // 8-bit character
UTCTL1 = SSEL0; // UCLK = ACLK
UBR01 = 0x0D; // 32k/2400 - 13.65
UBR11 = 0x00;
UMCTL1 = 0x6B; // Modulation
ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD
IE2 |= URXIE1;
IE2 |=UTXIE1; // Enable USART1 RX interrupt
P3SEL |= 0xC0; // P3.6,7 = USART1 option select
P3DIR |= 0x40; // P3.6 = output direction
_EINT(); // Enable interrupts
// Mainloop
for (;;)
{
_BIS_SR(LPM3_bits); // Enter LPM3
_NOP(); // Required only for C-spy
}
}
// UART1 RX ISR will for exit from LPM3 in Mainloop
interrupt[UART1RX_VECTOR] void usart1_rx (void)
{
_BIC_SR_IRQ(LPM3_bits);
while ((IFG2 & UTXIFG1) == 0); // USART1 TX buffer ready?
TXBUF1 = RXBUF1; // RXBUF1 to TXBUF1
}
程序运行到 while ((IFG2 & UTXIFG1) == 0); // USART1 TX buffer ready?
就执行不下去了!不知道为什么?请大家指点!谢谢!
report中显示为:
FETCH access at address 0xFF4A (Memory) - foreign
Break at FF50
FETCH access at address 0xFF50 (Memory) - foreign
Break at .fet140_uart11_02400.c\61 (usart1_rx) 答 1: 不小心写错一条语句!已经解决!呵呵
//******************************************************************************
// MSP-FET430P140 Demo - USART1 UART 2400 Ultra-low Power Echo ISR, 32kHz ACLK
//
// Description; Echo a received character, RX ISR used. In the Mainloop UART1
// is made ready to receive one character with interrupt active. The Mainloop
// waits in LPM3. The UART1 ISR forces the Mainloop to exit LPM3 after
// receiving one character which echo's back the received character.
// ACLK = UCLK1 = LFXT1 = 32768, MCLK = SMCLK = DCO ~ 800k
// Baud rate divider with 32768hz XTAL 2400 = 32768Hz/2400 = 13.65 (000Dh)
// //*An external watch crystal is required on XIN XOUT for ACLK*//
//
// MSP430F149
// -----------------
// /|\| XIN|-
// | | | 32kHz
// --|RST XOUT|-
// | |
// | P3.6|----------->
// | | 2400 - 8N1
// | P3.7|<-----------
//
//
// M. Buccini
// Texas Instruments, Inc
// February 2002
// Built with IAR Embedded Workbench Version: 1.25A
//******************************************************************************
#include <MSP430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
UCTL1&=~SWRST;
UCTL1 = CHAR; // 8-bit character
UTCTL1 = SSEL0; // UCLK = ACLK
UBR01 = 0x0D; // 32k/2400 - 13.65
UBR11 = 0x00;
UMCTL1 = 0x6B; // Modulation
ME2 |= UTXE1 + URXE1; // Enable USART1 TXD/RXD
IE2 |= URXIE1;
IE2 |=UTXIE1; // Enable USART1 RX interrupt
P3SEL |= 0xC0; // P3.6,7 = USART1 option select
P3DIR |= 0x40; // P3.6 = output direction
_EINT(); // Enable interrupts
// Mainloop
for (;;)
{
_BIS_SR(LPM3_bits); // Enter LPM3
_NOP(); // Required only for C-spy
}
}
// UART1 RX ISR will for exit from LPM3 in Mainloop
interrupt[UART1RX_VECTOR] void usart1_rx (void)
{
_BIC_SR_IRQ(LPM3_bits);
while ((IFG2 & UTXIFG1) == 0); // USART1 TX buffer ready?
TXBUF1 = RXBUF1; // RXBUF1 to TXBUF1
}
程序运行到 while ((IFG2 & UTXIFG1) == 0); // USART1 TX buffer ready?
就执行不下去了!不知道为什么?请大家指点!谢谢!
report中显示为:
FETCH access at address 0xFF4A (Memory) - foreign
Break at FF50
FETCH access at address 0xFF50 (Memory) - foreign
Break at .fet140_uart11_02400.c\61 (usart1_rx) 答 1: 不小心写错一条语句!已经解决!呵呵
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图四被打赏50分 | |
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 |