?? uart_run1.c
字號:
//******************************************************************************
// MSP430x26x Demo - USCI_A0, 115200 UART Echo ISR, DCO SMCLK
//
// Description: Echo a received character, RX ISR used. Normal mode is LPM0.
// USCI_A0 RX interrupt triggers TX Echo.
// Baud rate divider with 1MHz = 1MHz/115200 = ~8.7
// ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
//
// MSP430F261x/241x
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P3.4/UCA0TXD|------------>
// | | 115200 - 8N1
// | P3.5/UCA0RXD|<------------
//
// B. Nisarga
// edit by luoqinghua from Texas Instruments Inc.
// octobor 12 2007
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.42A
//******************************************************************************
//file name : uart_run1.c
#include "msp430x26x.h"
#include "uart.h"
//#include "uart1.c"
/***********************************************************************************
* @fn printInt
*
* @brief Print a 32-bit integer as decimal.
*
* @param v - the value to be displayed
*
* @return none
*/
void main(void)
{
int i;
uint8 data[50];
//char a="a";
int length=50;
uint32 mydata=100;
char *sz="i am in HEU.\n";
char chipID[]=" Hey ,i am using the format print";
uint16 chipid=0xffab;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 8; // 1MHz 115200
UCA0BR1 = 0; // 1MHz 115200
UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
//printf("hell0");
for(i = 0; i < length; i++)
{
data[i]=i;
printHex(i,8);
}
printChar('\n');
halUartWrite(data,50); //寫數據
printChar('\n');
printStr( sz);
printChar('a'); //寫字符
printStrW(sz, 10);
printChar('\n');//換行
printHex(mydata, 8);
printChar('\n');
printKvpHex(chipID, chipid);// printKvpHex("Chip ID: ", chipId);
printInt(mydata);
printChar('\n');//換行
printKvpInt("mydata is", mydata);
// __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
//#pragma vector=USCIAB0RX_VECTOR
//__interrupt void USCI0RX_ISR(void)
//{
// while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
// UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
//}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -