|
时钟配置....
CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting 8MHZ
CSCTL2 = SELA_0 + SELS_3 + SELM_3; // set ACLK = XT1; MCLK = DCO
CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers
CSCTL4 |= XT1DRIVE_0;
CSCTL4 &= ~XT1OFF;
模块配置....
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCMST+UCSYNC+UCCKPL+UCMSB+UCSSEL_2; // 3-pin, 8-bit SPI master Clock polarity high, MSB , SMCLK=DCO
UCA0BR0 = 0x02; // /2 baud
UCA0BR1 = 0; //
UCA0MCTLW = 0; // No modulation
UCA0STATW|=UCLISTEN; //Receive the transmitted;
UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
//UCA0IE |= UCTXIE; // Enable USCI_A0 TX interrupt We will use no interruption.
然后开始写
void spiw(unsigned char word)
{
while((UCA0IFG&UCTXIFG)==0);
UCA0TXBUF=word;
};
出问题了....写入一个字节后,UCTXIFG应该按照说明书自动清零才对,为什么没自动清零呢?而且发送寄存器根本不移位... |
阿莫论坛20周年了!感谢大家的支持与爱护!!
该献的血还是要献的。你不献他不献。难道让我去献? --- 出自坛友:lovejp1981
|