我使用的单片机是MSP430f4152,红外发射端接在P6.6(UCA0TXD),调制口接在P3.0(TA1.2)#include <msp430x41x2.h>
void int_uart()
{
P6SEL |= BIT5+BIT6; // P6.5,6 = USCI_A0 RXD/TXD
UCA0CTL0=UCPEN+UCPAR; //开校验位,偶校验
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 27; // 32k/1200
UCA0BR1 = 0x00; //
UCA0MCTL = 0x12; // Modulation
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
}
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP11PF; // Configure load caps
int_uart();
P3DIR |= 0x01; // P3.0 output
P3SEL |= 0x01; // P3.0 TA1 option
CCR0 = 26; // PWM Period
CCTL1 = OUTMOD_7; // CCR1 reset/set
CCR1 = 13; // CCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
CCTL0|= CCIE;
_EINT();//----------------------------------------------------->开总中断
for(;;)
{
LPM3;//--------------------------------------------------->进LPM3模式
_NOP();
}
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
while(!(IFG2&UCA0TXIFG));
UCA0TXBUF =0xff;
}
查看示波器的一端,输出时正旋波,数据发送的好像不对,接收端也收不到数据 |