页次: 1
如题求助,参考了很多源代码自己写了一点
基本的读写寄存器已经做到了,测试无错误,
发射方面用的是STM8S+SI4432,SPI通信,PH+FIFO+GFSK
发射频率: 435.355Mhz
晶振设置: 12ppm
晶体速率: 30Mhz
频率偏移: 无
频率偏差: 10khz
AFC: 开启
数据传输率: 1.2kbps
接收方面用的是WD21 无线模块,使用软件设置接收频率
接收频率: 435.355Mhz
模块波特率: 9600bps
空中波特率: 9600bps
虽然读写寄存器成功(用Silicons Labs提供的xls文件计算value),但是发射信号后无线模块却什么也接收不到。MCU方面有试过其他程序,可以确定MCU初始化没问题。
void SI4432_INIT(void)
{
SPI_Read(0x03);
SPI_Read(0x04);
lcd_write_text("start", 10,0,0);
phyWrite(0x07, 0x80); //reset register values to default
SPI_Read(0x03);
SPI_Read(0x04);
SPI_Read(0x03);
SPI_Read(0x04);
//////////////////435.355MHZ 设定///////////////////////////////////////////////////////////////////////
phyWrite(0x75, 0x53); // set frequency band
phyWrite(0x76, 0x85); // set nominal carrier frequency 1
phyWrite(0x77, 0xe0); // set nominal carrier frequency 0
//////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////1.2kbps 设定//////////////////////////////////////////////////////////////////////
phyWrite(0x6e, 0x09); //tx data rate
phyWrite(0x6f, 0xd5); // tx data rate
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////频率偏差/////////////////////////////////////////////////////////////////////
phyWrite(0x70, 0x2c); // manchester coding disabled
phyWrite(0x71, 0x23); // FIFO mode, GFSK modulated
phyWrite(0x72, 0x10); // tx deviation 10KHz
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////频率偏移////////////////////////////////////////////////////////////////////
phyWrite(0x73, 0x00); //no frequency offset
phyWrite(0x74, 0x00); // no frequency offset
///////////////////////////////////////////////////////////////////////////////////////////////////////////
phyWrite(0x7a, 0x0a);
phyWrite(0x79, 0x01);
phyWrite(0x07, 0x01); // 进入ready模式
phyWrite(0x09, 0x7f); // 晶振精度 12ppm
phyWrite(0x0b, 0xea); // SI4432 GPIO 0 (无视不使用)
phyWrite(0x0c, 0xea); // SI4432 GPIO 1 (无视不使用)
phyWrite(0x0d, 0xf4); // SI4432 GPIO 2 (无视不使用)
phyWrite(0x6d, 0x19); // tx power 18dbm
phyWrite(0x30, 0xac); // 使用PH+FIFO mode,CRC使能
phyWrite(0x32, 0x00); // byte0, header control
phyWrite(0x33, 0x02);// 使用同步字3,2
phyWrite(0x34, 0x08); // 前导码长度 25个字节
phyWrite(0x35, 0x42); // 前导码侦测控制1(不太清楚怎么设)
phyWrite(0x36, 0x2d); //同步字3 2D
phyWrite(0x37, 0xD4); //同步字2 D4
phyWrite(0x38, 0x00); //同步字1
phyWrite(0x39, 0x00); //同步字0
phyWrite(0x3a, 0x00); // transmit header 3
phyWrite(0x3b, 0x00); // transmit header 2
phyWrite(0x3c, 0x00); // transmit header 1
phyWrite(0x3d, 0x00); // transmit header 0
phyWrite(0x3f, 0x00); //check header 3
phyWrite(0x40, 0x00); //check header 2
phyWrite(0x41, 0x00); //check header 1
phyWrite(0x42, 0x00); //check header 0
phyWrite(0x43, 0xff); //header value 3
phyWrite(0x44, 0xff); //header value 2
phyWrite(0x45, 0xff); //header value 1
phyWrite(0x46, 0xff); //header value 0
}
void txdata(void)
{
unsigned char txdata[9];
//unsigned char i;
//tx test data is use to test the sended out signal
lcd_write_text("start tx", 10,0,0);
for (nCount=0 ; nCount<8; nCount++)
{
txdata[nCount] = 0x30 + nCount ;
}
//Flag.is_tx = 1
//delay(100);
phyWrite(0x07, 0x01); // SI4432进入准备模式
delay(10);
phyWrite(0x08, 0x01); // 清空tx fifo
delay(10);
phyWrite(0x08, 0x00); // 清空tx fifo
delay(10);
//phyWrite(0x08, 0x02); // 使能自动切传输与切换
//delay(10);
phyWrite(0x3e, 0x08); // 送出8个字节 payload length, the number of bytes you are going to send
for (xCount = 0; xCount<8; xCount++)
{
phyWrite(0x7f, txdata[xCount]); // put the data intended to send out into loading area, fifo loading area
delay(10);
}
phyWrite(0x05, 0x04); // 发出packet sent interrupt
phyWrite(0x06, 0x00);// disable interrupt
phyWrite(0x07, 0x09); // 打包tx fifo里的字节然后发出 pack tx data and send
delay(10);
phyWrite(0x05, 0x03); // signal valid packed sent
phyWrite(0x06, 0x00);// disable interrupt
SPI_Read(0x03); //重置interrupt
SPI_Read(0x04); // 重置interrupt
lcd_write_text("TX DoNE", 10,0,0);
phyWrite(0x07, 0x01);
delay(20);
//phyWrite(0x07, 0x05); //SI4432转接收模式
//delay(1);
}
希望大神可以指点出错误,感激不尽
页次: 1