用CC430F5137,FSK调试成功了,但ASK死活收不到。
发射器和接收器的配置是一样的。发射器确实发射出来了,数据可以通过示波器捕捉到。但接收器就是收不到。
配置如下:
//中频 = 26M / (2 ^ 10) * 8 = 203,125
WriteSingleReg(FSCTRL1, 0x08);
//默认值
WriteSingleReg(FSCTRL0, 0x00);
//载波频率 = 26M / (2 ^ 16) * 0x10b071 = 433,919,830.322265625
WriteSingleReg(FREQ2, 0x10);
WriteSingleReg(FREQ1, 0xB0);
WriteSingleReg(FREQ0, 0x71);
//带宽 = 26M / 8 / (4 + 2) / (2 ^ 1) = 270,833.333
//波特率 = (256 + 0x83) * (2 ^ 8) / (2 ^ 28) * 26M = 9,595.8709716796875
WriteSingleReg(MDMCFG4, 0x68);
WriteSingleReg(MDMCFG3, 0x83);
//Disable DC Blocking过滤器
//ASK
//Disable 曼彻斯特
//没有前导、同步字,不需要检测CS
WriteSingleReg(MDMCFG2, 0xb0);
//前导字节2字节
//信道间隔 = 26M / (2 ^ 18) * (256 + 0xf8) * (2 ^ 2) = 199,951.171875
WriteSingleReg(MDMCFG1, 0x02);
WriteSingleReg(MDMCFG0, 0xF8);
//频道号
WriteSingleReg(CHANNR, 0x00);
//频偏(用不着)
WriteSingleReg(DEVIATN, 0x40);
//
WriteSingleReg(FREND1, 0x56);
//设置了PA
WriteSingleReg(FREND0, 0x11);
//从IDLE模式变成RX, TX(包括FSTXON)时, 自动校准频率
WriteSingleReg(MCSM0, 0x18);
WriteSingleReg(MCSM1, 0x00);
//频率漂移补偿的设置:
//Enable补偿
//在检测到同步字之前,补偿3k
//检测到同步字后,补偿上述值的一半
//最多补偿带宽的1/4
WriteSingleReg(FOCCFG, 0x16);
//默认值
WriteSingleReg(BSCFG, 0x6c);
WriteSingleReg(AGCCTRL2, 0x43);
WriteSingleReg(AGCCTRL1, 0x40);
WriteSingleReg(AGCCTRL0, 0x93);
//频率合成器的校准
WriteSingleReg(FSCAL3, 0xe9);
WriteSingleReg(FSCAL2, 0x2A);
WriteSingleReg(FSCAL1, 0x00);
WriteSingleReg(FSCAL0, 0x1f);
WriteSingleReg(FSTEST, 0x59);
WriteSingleReg(TEST2, 0x81);
WriteSingleReg(TEST1, 0x35);
WriteSingleReg(TEST0, 0x09);
WriteSingleReg(IOCFG2, 0x09);
WriteSingleReg(IOCFG0, 0x2d);
//PQT = 0
//Disable CRC失败时Flush RXFIFO
//不添加2字节的LQI和CRC, RSSI
//无地址检测
WriteSingleReg(PKTCTRL1, 0x00);
//Disable白化
//正常模式(非同步/异步模式)
//Disable CRC
//包长固定(包长的值由PKTLEN指定)
WriteSingleReg(PKTCTRL0, 0x00);
WriteSingleReg(ADDR, 0x00);
WriteSingleReg(PKTLEN, sizeof(RX_BUF));
但有一个奇怪现象:如果我把同步字设置为0xaa,0xaa, 接收端就可以收到数据,但数据都是0xaa, 不管我发射端实际发射的真正数据是什么,它似乎把同步字节(或者前导字节)当成了数据! |