⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nrf905.lis

📁 嵌入式单片机控制温度传感的无线收发方案!
💻 LIS
📖 第 1 页 / 共 3 页
字号:
                        .module nrf905.c
                        .area text(rom, con, rel)
 0000                   .dbfile E:\公司用\atmega8l\final\nrf905_send1\nrf905.c
 0000                   .dbfunc e clear_Tx_Buf _clear_Tx_Buf fV
 0000           ;              i -> R16,R17
                        .even
 0000           _clear_Tx_Buf::
 0000                   .dbline -1
 0000                   .dbline 122
 0000           ; #include "confg.h"
 0000           ;  uchar Tx_Buf[SIZE];
 0000           ;  uchar Rx_Buf[SIZE];
 0000           ; 
 0000           ; //extern void delay_us(uint us);
 0000           ; uchar nrf905_SpiRW(uchar val);
 0000           ; void nrf905_SpiTest(void);
 0000           ; 
 0000           ; #define SIZE 32
 0000           ; 
 0000           ; //unsigned long  TX_ADDRESS=0x11111111;
 0000           ; /*-------------------------------------------------------------------------------------------
 0000           ; nrf905配置寄存器宏定义 author:HotPower
 0000           ;         nrf905配置寄存器(10Byte)
 0000           ; 工作频率f=(422.4+CH_NO/10)*(1+HFREQ_PLL)MHz
 0000           ; -------------------------------------------------------------------------------------------*/
 0000           ; #define RX_ADDRESS          0x11111101              //接收有效地址(本方)
 0000           ; #define TX_ADDRESS          0x11111111               //发送有效地址(对方)
 0000           ; 
 0000           ; #define CH_NO_FREQ_422_4MHz  0x000                     //工作频率422.4MHz(433MHz频段最低频率)
 0000           ; #define CH_NO_FREQ_422_5MHz  0x001                     //工作频率422.5MHz
 0000           ; #define CH_NO_FREQ_425_0MHz  0x01a                     //工作频率425.0MHz
 0000           ; #define CH_NO_FREQ_427_5MHz  0x033                     //工作频率427.5MHz
 0000           ; 
 0000           ; #define CH_NO_FREQ_430_0MHz  0x04c                     //工作频率430.0MHz
 0000           ; #define CH_NO_FREQ_433_0MHz  0x06a                     //工作频率433.0MHz(433MHz频段基准频率)
 0000           ; #define CH_NO_FREQ_433_1MHz  0x06b                     //工作频率433.1MHz
 0000           ; #define CH_NO_FREQ_433_2MHz  0x06c                     //工作频率433.2MHz
 0000           ; #define CH_NO_FREQ_434_7MHz  0x07b                     //工作频率434.7MHz
 0000           ; #define CH_NO_FREQ_473_5MHz  0x1ff                     //工作频率473.5MHz(433MHz频段最高频率)
 0000           ; 
 0000           ; #define CH_NO_FREQ_844_8MHz  0x000                     //工作频率844.8MHz(868MHz频段最低频率)
 0000           ; 
 0000           ; #define CH_NO_FREQ_862_0MHz  0x056                     //工作频率862.0MHz
 0000           ; #define CH_NO_FREQ_868_0MHz  0x074                     //工作频率868.0MHz(868MHz频段基准频率)
 0000           ; #define CH_NO_FREQ_868_2MHz  0x075                     //工作频率868.2MHz
 0000           ; #define CH_NO_FREQ_868_4MHz  0x076                     //工作频率868.4MHz
 0000           ; #define CH_NO_FREQ_869_8MHz  0x07d                     //工作频率869.8MHz
 0000           ; #define CH_NO_FREQ_895_8MHz  0x0ff                     //工作频率895.8MHz
 0000           ; #define CH_NO_FREQ_896_0MHz  0x100                     //工作频率896.0MHz
 0000           ; #define CH_NO_FREQ_900_0MHz  0x114                     //工作频率900.0MHz
 0000           ; #define CH_NO_FREQ_902_2MHz  0x11f                     //工作频率902.2MHz
 0000           ; #define CH_NO_FREQ_902_4MHz  0x120                     //工作频率902.4MHz
 0000           ; #define CH_NO_FREQ_915_0MHz  0x15f                     //工作频率915.0MHz(915MHz频段基准频率)
 0000           ; #define CH_NO_FREQ_927_8MHz  0x19f                     //工作频率927.8MHz
 0000           ; 
 0000           ; #define CH_NO_FREQ_947_0MHz  0x1ff                     //工作频率947.0MHz(915MHz频段最高频率)
 0000           ; 
 0000           ; #define CH_NO_FREQ           CH_NO_FREQ_430_0MHz       //工作频率433.0MHz
 0000           ; 
 0000           ; 
 0000           ; #define CH_NO_BYTE           CH_NO_FREQ & 0xff         //工作频率低8位       Byte0       01101100
 0000           ; 
 0000           ; #define AUTO_RETRAN          0x20                      //重发数据包          Byte1.5     0
 0000           ; #define RX_RED_PWR           0x10                      //接收低功耗模式      Byte1.4     0
 0000           ; #define PA_PWR__10dBm        0x00                      //输出功率-10dBm      Byte1.3~2   00
 0000           ; #define PA_PWR_2dBm          0x04                      //输出功率+2dBm       Byte1.3~2
 0000           ; #define PA_PWR_6dBm          0x08                      //输出功率+6dBm       Byte1.3~2
 0000           ; #define PA_PWR_10dBm         0x0c                      //输出功率+10dBm      Byte1.3~2   
 0000           ; #define HFREQ_PLL_433MHz     0x00                      //工作在433MHz频段    Byte1.1     0
 0000           ; #define HFREQ_PLL_868MHz     0x02                      //工作在868MHz频段    Byte1.1
 0000           ; #define HFREQ_PLL_915MHz     0x02                      //工作在915MHz频段    Byte1.1
 0000           ; #define CH_NO_BIT8           CH_NO_FREQ >> 8           //工作频率第9位       Byte1.0     0
 0000           ; 
 0000           ; #define TX_AFW_1BYTE         1 * 16                    //发送地址宽度1字节   Byte2.7~4
 0000           ; #define TX_AFW_2BYTE         2 * 16                    //发送地址宽度2字节   Byte2.7~4
 0000           ; #define TX_AFW_3BYTE         3 * 16                    //发送地址宽度3字节   Byte2.7~4
 0000           ; #define TX_AFW_4BYTE         4 * 16                    //发送地址宽度4字节   Byte2.7~4   100
 0000           ; #define RX_AFW_1BYTE         1                         //接收地址宽度1字节   Byte2.3~0
 0000           ; #define RX_AFW_2BYTE         2                         //接收地址宽度2字节   Byte2.3~0
 0000           ; #define RX_AFW_3BYTE         3                         //接收地址宽度3字节   Byte2.3~0
 0000           ; #define RX_AFW_4BYTE         4                         //接收地址宽度4字节   Byte2.3~0   100
 0000           ; 
 0000           ; #define RX_PW_1BYTE          1                         //接收数据宽度1字节   Byte3.5~0
 0000           ; #define RX_PW_32BYTE         32                        //接收数据宽度32字节  Byte3.5~0   00100000
 0000           ; #define TX_PW_1BYTE          1                         //发送数据宽度1字节   Byte4.5~0 
 0000           ; #define TX_PW_32BYTE         32                        //发送数据宽度32字节  Byte4.5~0   00100000
 0000           ; 
 0000           ; #define RX_ADDRESS_0         RX_ADDRESS >> 24          //接收有效地址第1字节 Byte5       11100111
 0000           ; #define RX_ADDRESS_1         (RX_ADDRESS >> 16) & 0xff //接收有效地址第2字节 Byte6       11100111 
 0000           ; #define RX_ADDRESS_2         (RX_ADDRESS >> 8) & 0xff  //接收有效地址第3字节 Byte7       11100111
 0000           ; #define RX_ADDRESS_3         RX_ADDRESS & 0xff         //接收有效地址第4字节 Byte8       11100111
 0000           ;        
 0000           ; #define CRC_MODE_16BIT       0x80                      //CRC16模式           Byte9.7     1
 0000           ; #define CRC_MODE_8BIT        0x00                      //CRC8模式            Byte9.7     
 0000           ; #define CRC_EN               0x40                      //CRC使能             Byte9.6     1
 0000           ; #define CRC16_EN             0xc0                      //CRC16模式使能       Byte9.7~6   11
 0000           ; #define CRC8_EN              0x40                      //CRC8模式使能        Byte9.7~6
 0000           ; #define XOF_20MHz            0x20                      //晶体振荡器频率20MHz Byte9.5~3
 0000           ; #define XOF_16MHz            0x18                      //晶体振荡器频率16MHz Byte9.5~3   100
 0000           ; #define XOF_12MHz            0x10                      //晶体振荡器频率12MHz Byte9.5~3
 0000           ; #define XOF_8MHz             0x08                      //晶体振荡器频率8MHz  Byte9.5~3
 0000           ; #define XOF_4MHz             0x00                      //晶体振荡器频率4MHz  Byte9.5~3
 0000           ; #define UP_CLK_EN            0x40                      //输出时钟使能        Byte9.2     1
 0000           ; #define UP_CLK_FREQ_500kHz   0x03                      //输出时钟频率500kHz  Byte9.1~0   11
 0000           ; #define UP_CLK_FREQ_1MHz     0x02                      //输出时钟频率1MHz    Byte9.1~0
 0000           ; #define UP_CLK_FREQ_2MHz     0x01                      //输出时钟频率2MHz    Byte9.1~0
 0000           ; #define UP_CLK_FREQ_4MHz     0x00                      //输出时钟频率4MHz    Byte9.1~0
 0000           ; 
 0000           ; #define UP_CLK_EN_500kHz     0x43                      //输出时钟频率500kHz  Byte9.2~0   111
 0000           ; #define UP_CLK_EN_1MHz       0x42                      //输出时钟频率1MHz    Byte9.2~0
 0000           ; #define UP_CLK_EN_2MHz       0x41                      //输出时钟频率2MHz    Byte9.2~0
 0000           ; #define UP_CLK_EN_4MHz       0x40                      //输出时钟频率4MHz    Byte9.2~0
 0000           ; 
 0000           ; #define TX_ADDRESS_0         TX_ADDRESS >> 24          //发送有效地址第1字节
 0000           ; #define TX_ADDRESS_1         (TX_ADDRESS >> 16) & 0xff //发送有效地址第2字节
 0000           ; #define TX_ADDRESS_2         (TX_ADDRESS >> 8) & 0xff  //发送有效地址第3字节
 0000           ; #define TX_ADDRESS_3         TX_ADDRESS & 0xff         //发送有效地址第4字节
 0000           ; 
 0000           ; /*-----------------------------------------------
 0000           ;         nrf905命令控制字 author:HotPower
 0000           ; ------------------------------------------------*/
 0000           ; #define WC        0x00            // Write configuration register command
 0000           ; #define RC        0x10            // Read  configuration register command
 0000           ; #define WTP       0x20            // Write TX Payload  command
 0000           ; #define RTP       0x21            // Read  TX Payload  command
 0000           ; #define WTA       0x22            // Write TX Address  command
 0000           ; #define RTA       0x23            // Read  TX Address  command
 0000           ; #define RRP       0x24            // Read  RX Payload  command
 0000           ;  
 0000           ; void clear_Tx_Buf(void) //清空发送缓冲
 0000           ;   {
 0000                   .dbline 124
 0000           ;   int i;
 0000           ;   for (i=0;i<32;i++) 
 0000 0027              clr R16
 0002 1127              clr R17
 0004           L2:
 0004                   .dbline 125
 0004 80E0              ldi R24,<_Tx_Buf
 0006 90E0              ldi R25,>_Tx_Buf
 0008 F801              movw R30,R16
 000A E80F              add R30,R24
 000C F91F              adc R31,R25
 000E 2224              clr R2
 0010 2082              std z+0,R2
 0012           L3:
 0012                   .dbline 124
 0012 0F5F              subi R16,255  ; offset = 1
 0014 1F4F              sbci R17,255
 0016                   .dbline 124
 0016 0032              cpi R16,32
 0018 E0E0              ldi R30,0
 001A 1E07              cpc R17,R30
 001C 9CF3              brlt L2
 001E                   .dbline -2
 001E                   .dbline 126
 001E           ;   Tx_Buf[i]='';
 001E           ;   }
 001E           L1:
 001E                   .dbline 0 ; func end
 001E 0895              ret
 0020                   .dbsym r i 16 I
 0020                   .dbend
 0020                   .dbfunc e Read_nrf905Add _Read_nrf905Add fV
                        .even
 0020           _Read_nrf905Add::
 0020 00D0              rcall push_gset2
 0022                   .dbline -1
 0022                   .dbline 130
 0022           ;   
 0022           ; void Read_nrf905Add(void)
 0022           ;   //读取nrf905的接受发送地址
 0022           ;   {
 0022                   .dbline 131
 0022           ;      Tx_Buf[0]=(int)RX_ADDRESS;//子机地址
 0022 41E0              ldi R20,1
 0024 51E1              ldi R21,17
 0026 61E1              ldi R22,17
 0028 71E1              ldi R23,17
 002A 1A01              movw R2,R20
 002C 20922000          sts _Tx_Buf,R2
 0030                   .dbline 132
 0030           ;        Tx_Buf[1]=0x03;//命令字
 0030 83E0              ldi R24,3
 0032 80932100          sts _Tx_Buf+1,R24
 0036                   .dbline -2
 0036                   .dbline 133
 0036           ;   }
 0036           L6:
 0036 00D0              rcall pop_gset2
 0038                   .dbline 0 ; func end
 0038 0895              ret
 003A                   .dbend
 003A                   .dbfunc e nrf905_Config _nrf905_Config fV
                        .even
 003A           _nrf905_Config::
 003A                   .dbline -1
 003A                   .dbline 137
 003A           ; 
 003A           ; //配置nRF905
 003A           ; void nrf905_Config(void)//通过向spi 向905写寄存器从而配置寄存器
 003A           ; {
 003A                   .dbline 138
 003A           ;   CLR(PORTB,CSN);                   // Spi 片选开,使能spi
 003A C298              cbi 0x18,2
 003C                   .dbline 139
 003C           ;   nrf905_SpiRW(WC);                // Write config command ,
 003C 0027              clr R16
 003E 16D0              rcall _nrf905_SpiRW
 0040                   .dbline 140
 0040           ;   nrf905_SpiRW(CH_NO_BYTE);                      //中心频率低8位
 0040 0CE4              ldi R16,76
 0042 14D0              rcall _nrf905_SpiRW
 0044                   .dbline 142
 0044           ;   //nrf905_SpiRW(PA_PWR_10dBm | HFREQ_PLL_433MHz); //发射+10dBm,发射频率433MHz,中心频率第9位=0
 0044           ;   nrf905_SpiRW(PA_PWR__10dBm | HFREQ_PLL_433MHz); //发射+10dBm,发射频率433MHz,中心频率第9位=0
 0044 0027              clr R16
 0046 12D0              rcall _nrf905_SpiRW
 0048                   .dbline 143
 0048           ;   nrf905_SpiRW(TX_AFW_4BYTE | RX_AFW_4BYTE);     //接收地址宽度4字节,发送地址宽度4字节
 0048 04E4              ldi R16,68
 004A 10D0              rcall _nrf905_SpiRW
 004C                   .dbline 144
 004C           ;   nrf905_SpiRW(RX_PW_32BYTE);                    //接收数据宽度32字节
 004C 00E2              ldi R16,32
 004E 0ED0              rcall _nrf905_SpiRW
 0050                   .dbline 145
 0050           ;   nrf905_SpiRW(TX_PW_32BYTE);                    //发送数据宽度32字节
 0050 00E2              ldi R16,32
 0052 0CD0              rcall _nrf905_SpiRW
 0054                   .dbline 146
 0054           ;   nrf905_SpiRW(RX_ADDRESS_0);                    //接收有效地址第1字节
 0054 01E1              ldi R16,17
 0056 0AD0              rcall _nrf905_SpiRW
 0058                   .dbline 147
 0058           ;   nrf905_SpiRW(RX_ADDRESS_1);                    //接收有效地址第2字节

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -