hal_uart.c
上传用户:zhingjinbo
上传日期:2014-07-24
资源大小:32k
文件大小:1k
- #include "include.h"
- //----------------------------------------------------------------------------
- // Functions for sending debug strings to a UART. Although the same interfaces
- // defined for SPI (USARTn, USCIxn, USI, and bit-bang) could be used for UART,
- // only USART0/1 are defined.
- //----------------------------------------------------------------------------
- void halUARTSetup(void)
- {
- P2SEL |= 0x010; // P2.4 = USCI_A0 TXD
- UCA0CTL1 |= UCSSEL_2; // SMCLK
- UCA0BR0 = 0x6D; // 1MHz 9600
- UCA0BR1 = 0x00; // 1MHz 9600
- UCA0MCTL = 4; // Modulation
- UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
- IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
- }
- void blastString(char string[], unsigned int len)
- {
- volatile unsigned int i;
- for(i=0;i<len;i++)
- {
- while (!(IFG2 & UCA0TXIFG)); // USART1 TX buffer ready?
- UCA0TXBUF = string[i]; // Output character
- }
- }