|
CC2500配置好了,但是还是不能通讯,不知道怎样确定是否正确发送或接收。
我的发送端程序如下:
uchar t_buf[2]={0x01,0x02};
int main(void)
{
Init();
POWER_UP_RESET_CCxxx0();
halRfWriteRfSettings(&rfSettings);
halSpiWriteReg(CCxxx0_PATABLE, paTable);
while(1)
{
halSpiStrobe(CCxxx0_SIDLE);
halRfSendPacket(t_buf,2);
_delay_ms(1000);
}
}
接收端程序如下:
uchar r_buf[2];
int main(void)
{
uchar len;
Init();
POWER_UP_RESET_CCxxx0();
halRfWriteRfSettings(&rfSettings);
halSpiWriteReg(CCxxx0_PATABLE, paTable);
while(1)
{
halSpiWriteReg(CCxxx0_PATABLE, paTable);
if(halRfReceivePacket(r_buf,&len))
{
t_buf[2]=r_buf[0];
t_buf[3]=r_buf[1];
SerialSend(); //通过串口将收到的数据发送到PC端
}
}
}
配置:
const RF_SETTINGS rfSettings = {
0x07, // FSCTRL1 Frequency synthesizer control.
0x00, // FSCTRL0 Frequency synthesizer control.
0x5D, // FREQ2 Frequency control word, high byte.
0x93, // FREQ1 Frequency control word, middle byte.
0xB1, // FREQ0 Frequency control word, low byte.
0x2D, // MDMCFG4 Modem configuration.
0x3B, // MDMCFG3 Modem configuration.
0x73, // MDMCFG2 Modem configuration.
0x22, // MDMCFG1 Modem configuration.
0xF8, // MDMCFG0 Modem configuration.
0x00, // CHANNR Channel number.
0x01, // DEVIATN Modem deviation setting (when FSK modulation is enabled).
0xB6, // FREND1 Front end RX configuration.
0x10, // FREND0 Front end RX configuration.
0x18, // MCSM0 Main Radio Control State Machine configuration.
0x1D, // FOCCFG Frequency Offset Compensation Configuration.
0x1C, // BSCFG Bit synchronization Configuration.
0xC7, // AGCCTRL2 AGC control.
0x00, // AGCCTRL1 AGC control.
0xB0, // AGCCTRL0 AGC control.
0xEA, // FSCAL3 Frequency synthesizer calibration.
0x0A, // FSCAL2 Frequency synthesizer calibration.
0x00, // FSCAL1 Frequency synthesizer calibration.
0x11, // FSCAL0 Frequency synthesizer calibration.
0x59, // FSTEST Frequency synthesizer calibration.
0x88, // TEST2 Various test settings.
0x31, // TEST1 Various test settings.
0x0B, // TEST0 Various test settings.
0x07, // FIFOTHR RXFIFO and TXFIFO thresholds.
0x29, // IOCFG2 GDO2 output pin configuration.
0x06, // IOCFG0D GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
0x04, // PKTCTRL1 Packet automation control.
0x01, // PKTCTRL0 Packet automation control.
0x00, // ADDR Device address.
0xFF // PKTLEN Packet length.
};
还麻烦大家帮我看下有没有什么问题。万分感谢!! |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|