|
因项目需求,要用到无线通信模块,刚好队友那里买了一对SI4432。研究了个把星期,把手册和编程指南都过了一遍,然后在网上找到相关的程序,移植到Atmega128上面,一番调试后,基本上算是通了,但很奇怪,传输距离只有5米的样子。然后以为是硬件问题(单片机用的是5V电压),队友赶着做了一块转接板,其实就是在单片机与模块间串入电阻,做好后一试,基本还是一样的。不得已,重新看资料,看寄存器配置,与其他的demo程序对比,发现模块的发射功率设小了,于是想当然的把寄存器改成了最大,然后。。。。悲剧发生了,有一块是下完程序后工作基本正常,还有一块下完后,发现除了能够启动外,其他什么都不正常了,把功率再次设低后,也恢复不了正常状态了,我想问问各位前辈,是不是因为模块功率被设置过大,烧坏了。。。。本人现在是自动化专业的学生,没学过高频跟通信,完全看不懂,手册上面的寄存器配置,完全是照着别人的程序来,下面把寄存器的配置部分贴出来给大家看看,是不是设置的有问题。先在此谢过了!- void Init_4432(void)
- {
- Init_spi();
- SpiWriteRegister(0x07, 0x80); //恢复所有寄存器为默认值
- Delayms(500);
-
- SpiWriteRegister(0x03, 0x00); //清除所有中断标志
- SpiWriteRegister(0x04, 0x00); //清除所有中断标志
- SpiWriteRegister(0x05, 0x00); //清除所有中断使能
- SpiWriteRegister(0x06, 0x00); //清除所有中断使能
- SpiWriteRegister(0x06, 0x80); //使能同步字侦测
- SpiWriteRegister(0x07, 0x01); //进入 Ready 模式
-
- SpiWriteRegister(0x09, 0x7f); //负载电容= 12P
- SpiWriteRegister(0x0a, 0x05); //关闭低频输出
- SpiWriteRegister(0x0b, 0xea); //GPIO 0 当做普通输出口
- SpiWriteRegister(0x0c, 0xea); //GPIO 1 当做普通输出口
- SpiWriteRegister(0x0d, 0xf4); //GPIO 2 输出收到的数据
- SpiWriteRegister(0x70, 0x2c);
- SpiWriteRegister(0x1d, 0x40); //使能 afc
-
- // 1.2K bps setting
- SpiWriteRegister(0x1c, 0x16); //IF滤波带宽
- SpiWriteRegister(0x20, 0x83);
- SpiWriteRegister(0x21, 0xc0); //
- SpiWriteRegister(0x22, 0x13); //
- SpiWriteRegister(0x23, 0xa9); //
- SpiWriteRegister(0x24, 0x00); //
- SpiWriteRegister(0x25, 0x04); //
- SpiWriteRegister(0x2a, 0x14);
- SpiWriteRegister(0x6e, 0x09);
- SpiWriteRegister(0x6f, 0xd5);
- //1.2K bps setting end
-
- SpiWriteRegister(0x30, 0x8c); //使能PH+ FIFO模式,高位在前面,使能CRC校验
- SpiWriteRegister(0x32, 0xff); //byte 0,1,2,3 作为头码
- SpiWriteRegister(0x33, 0x42); //byte 0,1,2,3 是头码,同步字3,2 是同步字
- SpiWriteRegister(0x34, 16); //发射16个Nibble的Preamble
- SpiWriteRegister(0x35, 0x20); //需要检测4个nibble的Preamble
- SpiWriteRegister(0x36, 0x2d); //同步字为 0x2dd4
- SpiWriteRegister(0x37, 0xd4);
- SpiWriteRegister(0x38, 0x00);
- SpiWriteRegister(0x39, 0x00);
- SpiWriteRegister(0x3a, 's'); //发射的头码为:"swwx"
- SpiWriteRegister(0x3b, 'w');
- SpiWriteRegister(0x3c, 'w');
- SpiWriteRegister(0x3d, 'x');
- SpiWriteRegister(0x3e, TxBuf_Len); //总共发射TxBuf_Len个字节的数据
- SpiWriteRegister(0x3f, 's'); //需要校验的头码为:"swwx"
- SpiWriteRegister(0x40, 'w');
- SpiWriteRegister(0x41, 'w');
- SpiWriteRegister(0x42, 'x');
- SpiWriteRegister(0x43, 0xff); //头码1,2,3,4 的所有位都需要校验
- SpiWriteRegister(0x44, 0xff); //
- SpiWriteRegister(0x45, 0xff); //
- SpiWriteRegister(0x46, 0xff); //
-
- SpiWriteRegister(0x6A, 0x0B); //write 0x0B to the AGC Override 2 register
- //set ADC reference voltage to 0.9V
- SpiWriteRegister(0x68, 0x04); //write 0x04 to the Deltasigma ADC Tuning 2 register
- SpiWriteRegister(0x1F, 0x03); //write 0x03 to the Clock Recovery Gearshift Override register
- 这里功率该设置多大好
- SpiWriteRegister(0x6d, 0x07); //发射功率设置 0x00:+1dBM 0x01:+2dBM 0x02:+5dBM 0x03:+8dBM 0x04:+11dBM 0x05:+14dBM 0x06:+17dBM 0x07:+20dBM
- SpiWriteRegister(0x79, 0x0); //不需要跳频
- SpiWriteRegister(0x7a, 0x0); //不需要跳频
- SpiWriteRegister(0x71, 0x22); //发射不需要CLK,FiFo,FSK模式
- SpiWriteRegister(0x72, 0x30); //频偏为 30KHz
- SpiWriteRegister(0x73, 0x0); //没有频率偏差
- SpiWriteRegister(0x74, 0x0); //没有频率偏差
- SpiWriteRegister(0x75, 0x53); //频率设置 434
- SpiWriteRegister(0x76, 0x57); //标称载波频率 57
- SpiWriteRegister(0x77, 0x80); //标称载波频率 80
- SpiWriteRegister(0x0e, 0x00); // 天线开关不在发射,接收状态
- }
复制代码 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|