1278 views|0 replies

2015

Posts

0

Resources
The OP
 

MSP430 serial port receiving program (using interruption) [Copy link]

Use the receive interrupt to resend the received characters. Each time a character is received, the low power mode will be exited, and the received characters will be resent in the main function. [html] view plain copy /*********************************************** *Program description: P3.4 and P3.5 of the microcontroller are used as serial ports to receive characters and resend the received characters *Author: Zhenhua Liu *Time: 2017.11.02 18:00 ***************************************************/ #include    
void usartInit(void); //Serial port initialization void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT usartInit(); while(1){ _BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt while((UTCTL0&TXEPT)==0);//Wait for data to be sent TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0 } } #pragma vector=UART0RX_VECTOR __interrupt void usart0_rx (void) { LPM3_EXIT; } /**************************************************************************** *Function name: uartInit() / *Function: Initialization configuration of USART0, use P3.4 and P3.5, use receive interrupt / *Return value: None / *Parameter: None / *Author: Zhenhua Liu / *Time: 2017.11.02 / *****************************************************************************/ void usartInit(){ P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD UCTL0 |= CHAR; // 8-bit character UTCTL0 |= SSEL0; // UCLK = ACLK UBR00 = 0x03; // 32k/9600 - 3.41 UBR10 = 0x00; // UMCTL0 = 0x4A; // Modulation UCTL0 &= ~SWRST; // Initialize USART state machine IE1 |= URXIE0; // Enable USART0 RX interrupt }  


This post is from Microcontroller MCU
 

Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list