主题:CC2500 中讨论的其他部件
工具/软件:
大家好、我需要帮助、我尝试通过 SPI 通信读取 CC2500 模块的芯片 ID(如下图所示)、以便在线路下进一步使用它。
这是 CC2500 的写入和读取操作:
以下是尝试读取和写入 CC2500 的代码:P1.0 LED 永远不会亮起
#include "intrinsics.h" #include "msp430f5529.h" #include <msp430.h> #include "msp430f5xx_6xxgeneric.h" #include <stdint.h> uint8_t Dados = 0x00; void send(); void read(); int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P1DIR |= 0x01; // P1.0 output P4DIR |= BIT7; // P4.7 output // LED desligados P1OUT &= ~BIT0; P4OUT &= ~BIT7; // SPI init - UCB0 UCB0CTL1 |= UCSWRST; UCB0CTL0 |= UCMST + UCSYNC + UCMODE_0; // Master mode + Slave enabled - CS low UCB0CTL1 |= UCSSEL_3; // SMCLK // Bit rate UCB0BR0 = 1; UCB0BR1 = 0; // Port SPI init - 3.0, 3.1, 3.2 e 2.7 P3SEL |= BIT0 + BIT1 + BIT2; P2DIR |= BIT7; P2OUT |= BIT7; //UCB0IE |= UCTXIE + UCRXIE; UCB0CTL1 &= ~UCSWRST; //__bis_SR_register(GIE); // enable interrupts send(); while (1) { read(); // Verificar leitura do registo - ID do modulo RF if (Dados == 0x80) { P4OUT |= BIT7; //__delay_cycles(160000); } else { P4OUT &= ~BIT7; //__delay_cycles(160000); } } } void send() { P2OUT &= ~BIT7; __delay_cycles(50); while(!(UCB0IFG & UCTXIFG)); UCB0TXBUF = 0x30; P2OUT |= BIT7; } void read() { //UCB0IFG &= ~(UCTXIFG + UCRXIFG); //UCB0IE |= UCRXIE; P2OUT &= ~BIT7; __delay_cycles(50); while(!(UCB0IFG & UCTXIFG)); UCB0TXBUF = 0xC0 | 0x30; while(!(UCB0IFG & UCRXIFG)); volatile uint8_t dummy = UCB0RXBUF; while(!(UCB0IFG & UCTXIFG)); UCB0TXBUF = 0x00; while(!(UCB0IFG & UCRXIFG)); Dados = UCB0RXBUF; P1OUT |= BIT0; //__bis_SR_register(GIE); //__bis_SR_register(LPM0_bits + GIE); //__no_operation(); P2OUT |= BIT7; }
这就是我在逻辑分析仪上看到的结果:
如果有人能帮助我尝试和找出什么错误,我会很高兴地感谢它谢谢!