刚搞了个VS1053模块,就试着弄弄 正弦测试成功了,但是读寄存器总是不对 uint8 RxFlag=0; uint8 RX_DATA[2]; void SPI_Init() { U0CTL = CHAR + SYNC + MM + SWRST; // 8-bit, SPI, master U0TCTL = SSEL1 + SSEL0 + STC; // Polarity, 3-wire U0TCTL&=~CKPL; U0BR0 = 0x02; // SPICLK = SMCLK/2 U0BR1 = 0x00; U0MCTL = 0x00; ME1 |= USPIE0; // Module enable U0CTL &= ~SWRST; // SPI enable IE1|=URXIE0; P3SEL |= 0x0E; // P3.1,2,3 SPI option select P3DIR |= 0x0A; } uint16 SPI_Read() //read from spi port { uint16 temp; while(RxFlag!=2); RxFlag=0; temp=RX_DATA[0]; temp<<=8; temp|=RX_DATA[1]; return temp; } #pragma vector=USART0RX_VECTOR __interrupt void UartRx() { RX_DATA[RxFlag++]=RXBUF0; } 总是返回的全是0 求助啊
[ 本帖最后由 yangyifeng01 于 2012-3-11 12:15 编辑 ]
|