找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2101|回复: 1
打印 上一主题 下一主题
收起左侧

430下的SI4432模块初始化

[复制链接]
跳转到指定楼层
楼主
ID:88321 发表于 2015-9-1 10:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

// ----------------------------------------------------------------------
// 无线模块初始化
// ----------------------------------------------------------------------
void RF_init(void)
{
    SpiWriteRegister(0x07, 0x80);//SW reset  //向0X07地址  写入0X80  软件复位
    while ( RF4432_IRQ == 1); //读取中断状态          清除中断  释放         SI4432_NIRQ
    ItStatus1 = SpiReadRegister(0x03);        //读取中断状态          清除中断  释放         SI4432_NIRQ                                                                                                //read the Interrupt Status1 register
    ItStatus2 = SpiReadRegister(0x04);                                                                                                        //read the Interrupt Status2 register


    SpiWriteRegister(0x06, 0x80);       
    SpiWriteRegister(0x07, 0x01);                                                                                                                        //write 0x80 to the Operating & Function Control1 register
    SpiWriteRegister(0x09, 0x64);                //云宝
    //SpiWriteRegister(0x09, 0x7f);     //思为

    SpiWriteRegister(0x0A, 0x05);  //关闭低频输出
    SpiWriteRegister(0x0B, 0xEA);  //GPIO 0 当做普通输出口
    SpiWriteRegister(0x0C, 0xEA);  //GPIO 1 当做普通输出口
    SpiWriteRegister(0x0D, 0xF4);  //GPIO 2 输出收到的数据

    SpiWriteRegister(0x70, 0x24);  //0x2c);  // 下面的设置根据Silabs 的Excel
    SpiWriteRegister(0x1D, 0x40);  // 使能 afc
       
    ///*/ 1.2K bps setting
    SpiWriteRegister(0x1C, 0x16);       
    SpiWriteRegister(0x20, 0x83);

        SpiWriteRegister(0x21, 0xc0);  //
        SpiWriteRegister(0x22, 0x13);  //
        SpiWriteRegister(0x23, 0xa9);  //
        SpiWriteRegister(0x24, 0x00);  //
        SpiWriteRegister(0x25, 0x04);  //
       
        SpiWriteRegister(0x2A, 0x14);// 1.2K bps 发射速率
        SpiWriteRegister(0x6E, 0x09);
        SpiWriteRegister(0x6F, 0xd5);
        //SI4432_WriteReg(0x70, 0x2c);//


        SpiWriteRegister(0x6D, 0x07);  //07 设置为最大功率发射
        SpiWriteRegister(0x0D, 0xFC);  //GPIO 2 信道空闲指示(常态为低,忙为高)
        SpiWriteRegister(0x79, 0x00);   // 不需要跳频
        SpiWriteRegister(0x7A, 0x00);   // 不需要跳频

        SpiWriteRegister(0x71, 0x22);  // 发射不需要 CLK,FiFo , FSK模式                       
        SpiWriteRegister(0x72, 0x30);  // 频偏为 30KHz
       
        SpiWriteRegister(0x73, 0x00);   // 没有频率偏差
        SpiWriteRegister(0x74, 0x00);   // 没有频率偏差
       
        //SpiWriteRegister(0x75, 0x53);  // 频率设置 433.5
        //SpiWriteRegister(0x76, 0x57);  //
        //SpiWriteRegister(0x77, 0x80);
        SpiWriteRegister(0x75, 0x60);  // 频率设置 490
        SpiWriteRegister(0x76, 0x7d);  //
        SpiWriteRegister(0x77, 0x00);                                                                                               
                                                               
        /*set the packet structure and the modulation type*/
        //set the preamble length to 10bytes
        SpiWriteRegister(0x34, 0x0C);                                                                                                                        //write 0x0A to the Preamble Length register
        //set preamble detection threshold to 20bits
        SpiWriteRegister(0x35, 0x2A);                                                                                                                 //write 0x2A to the Preamble Detection Control  register

        //Disable header bytes; set variable packet length (the length of the payload is defined by the
        //received packet length field of the packet); set the synch word to two bytes long
        SpiWriteRegister(0x33, 0x02);                                                                                                                        //write 0x02 to the Header Control2 register   
       
        //Set the sync word pattern to 0x2DD4
        SpiWriteRegister(0x36, 0x2D);                                                                                                                        //write 0x2D to the Sync Word 3 register
        SpiWriteRegister(0x37, 0xD4);                                                                                                                        //write 0xD4 to the Sync Word 2 register

        //enable the TX & RX packet handler and CRC-16 (IBM) check
        SpiWriteRegister(0x30, 0x8D);                                                                                                                        //write 0x8D to the Data Access Control register
        //Disable the receive header filters
        SpiWriteRegister(0x32, 0x00);
       
        /*enable receiver chain*/
        SpiWriteRegister(0x07, 0x05);        //打开接收                                                                                                                 //write 0x05 to the Operating Function Control 1 register
        //Enable two interrupts:
        // a) one which shows that a valid packet received: 'ipkval'
        // b) second shows if the packet received with incorrect CRC: 'icrcerror'
        SpiWriteRegister(0x05, 0x03);         //打开 接收中断                                                                                                        //write 0x03 to the Interrupt Enable 1 register
        SpiWriteRegister(0x06, 0x00);                                                                                                                 //write 0x00 to the Interrupt Enable 2 register
        //read interrupt status registers to release all pending interrupts
        ItStatus1 = SpiReadRegister(0x03);                                                                                                          //read the Interrupt Status1 register
        ItStatus2 = SpiReadRegister(0x04);
}


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:136504 发表于 2016-9-7 16:09 | 只看该作者
HW3000国产第一家433无线模块,完美替换si4432,4463.cc1101。一不小心就省了一辆宝马的钱。咨询电话:13570852936;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表