|
求教各位大侠,帮帮这个代码有什么问题,我检查了很久也没有检查出来,显示出来的什么都不是,乱码,可是我怎么检查波特率应该都没错的,请大侠帮忙
- void main(void)
- {
- WDTCTL = WDTPW + WDTHOLD; // stop watchdog
- int i,j;
-
- // XT1 Setup
-
- PJSEL0 |= BIT4 + BIT5;
- CSCTL0_H = 0xA5;
- CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting
- CSCTL2 = SELA_0 + SELS_0 + SELM_0; // set ACLK = XT1; MCLK = XTI=8m
- CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers
- CSCTL4 |= XT1DRIVE_0+XTS;
- CSCTL4 &= ~XT1OFF;
- do
- {
- CSCTL5 &= ~XT1OFFG;
- // Clear XT1 fault flag
- SFRIFG1 &= ~OFIFG;
- }while (SFRIFG1&OFIFG); // Test oscillator fault flag
-
- // Configure UART pins P2.0 & P2.1
- P2SEL1 |= BIT0 + BIT1;
- P2SEL0 &= ~(BIT0 + BIT1);
- PJDIR|=BIT0;
-
-
- // Configure UART 0
- UCA0CTL1 |= UCSWRST;
- UCA0CTL1 = UCSSEL_2; // Set SMCLK as UCLk
- UCA0BR0 =8 ; // 9600 baud
- // 8000000/(57600*16) - INT(8000000/(57600*16))=0.68
- UCA0BR1 = 0;
- // UCBRFx = a, UCBRSx = 0xb5, UCOS16 = 1 (Refer User Guide)
- UCA0MCTLW = 0xb5a1 ;
- UCA0CTL1 &= ~UCSWRST; // release from reset
- while(1)
- { // Vector 2 - RXIFG
- while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
- UCA0TXBUF ='a'; // TX -> RXed character
- PJOUT^=BIT0;
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|