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

📄 hello.lst

📁 CC1000通信
💻 LST
📖 第 1 页 / 共 5 页
字号:
__start:
__text_start:
    0061 EFCF      LDI	R28,0xFF
    0062 E1D0      LDI	R29,0x10
    0063 BFCD      OUT	0x3D,R28
    0064 BFDE      OUT	0x3E,R29
    0065 51C0      SUBI	R28,0x10
    0066 40D0      SBCI	R29,0
    0067 EA0A      LDI	R16,0xAA
    0068 8308      STD	Y+0,R16
    0069 2400      CLR	R0
    006A E0E0      LDI	R30,0
    006B E0F1      LDI	R31,1
    006C E011      LDI	R17,1
    006D 30E0      CPI	R30,0
    006E 07F1      CPC	R31,R17
    006F F011      BEQ	0x0072
    0070 9201      ST	R0,Z+
    0071 CFFB      RJMP	0x006D
    0072 8300      STD	Z+0,R16
    0073 ECE2      LDI	R30,0xC2
    0074 E0F0      LDI	R31,0
    0075 E0A0      LDI	R26,0
    0076 E0B1      LDI	R27,1
    0077 E010      LDI	R17,0
    0078 3CE2      CPI	R30,0xC2
    0079 07F1      CPC	R31,R17
    007A F021      BEQ	0x007F
    007B 95C8      LPM
    007C 9631      ADIW	R30,1
    007D 920D      ST	R0,X+
    007E CFF9      RJMP	0x0078
    007F 940E034D  CALL	_main
_exit:
    0081 CFFF      RJMP	_exit
_delaycc:
  i                    --> R20
  j                    --> R22
  t                    --> R16
    0082 940E039D  CALL	push_gset2
FILE: D:\FZCCC\cc1000avr.c
(0001) /****************************************************************************/
(0002) /* Application note AN009                                                   */
(0003) /* CC1000 interface library                                                 */
(0004) /*                                                                          */
(0005) /* File:      cc1000avr.c                                                   */
(0006) /* Revision:  2.1                                                           */
(0007) /*                                                                          */
(0008) /* Microcontroller:                                                         */
(0009) /*          Atmel AVRmega8L                                                 */
(0010) /* Written for the IAR AVR compiler                                         */
(0011) /*                                                                          */
(0012) /* Author:  Karl H. Torvmark, Field Applications Engineer, Chipcon          */
(0013) /*                                                                          */
(0014) /* Contact: Chipcon AS +47 22 95 85 44                                      */
(0015) /*          wireless@chipcon.com                                            */
(0016) /*                                                                          */
(0017) /* Changes:                                                                 */
(0018) /*      2.1 : First AVR version                                             */
(0019) /****************************************************************************/
(0020) 
(0021) /****************************************************************************/
(0022) /* This library contains functions for configuring the CC1000. These        */
(0023) /* routines use bit-banging to program the CC1000.                          */
(0024) /* Routines to read and write the calibration values in the CC1000 are      */
(0025) /* provided, they aree useful in frequency-agile and frequency hopping      */
(0026) /* applications. See application note AN009 for more information.           */
(0027) /* The routines in this file will have to be adapted depending on the MCU   */
(0028) /* and compiler used.                                                       */
(0029) /****************************************************************************/
(0030) 
(0031) /*                                                                           *
(0032)  * Revision history:                                                         *
(0033)  *                                                                           *
(0034)  * $Log: cc1000avr.c,v $
(0035)  * Revision 2.5  2003/05/08 10:51:52  tos
(0036)  * Corrected LOCK monitor in Calibrate.
(0037)  *
(0038)  * Revision 2.4  2003/05/08 10:05:26  tos
(0039)  * Corrections according to Errata Note 01: reset freq.synth if unable to lock PLL.
(0040)  *
(0041)  * Revision 2.3  2003/04/28 08:21:14  tos
(0042)  * Corrected inconsistent monitoring of CC1000: [calibration complete] + [lock].
(0043)  *
(0044)  *
(0045)  *                                                                           *
(0046)  ****************************************************************************/
(0047) 
(0048) #include "CC1000.h"
(0049) #include "iom128v.h"
(0050) #include <stdio.h>
(0051) 
(0052) /* Pin usage definitions */
(0053) /*#define PDATA       2   
(0054) // PORTB, pin 2
(0055) #define PCLK        1   
(0056) // PORTB, pin 1
(0057) #define PALE        6   
(0058) // PORTA, pin 6
(0059) #define DIO         6   
(0060) // PORTE, pin 6
(0061) #define DCLK        6   
(0062) // PORTB, pin 6
(0063) /**/
(0064) #define PDATA       3   // PORTD, pin 3
(0065) #define PCLK        4   // PORTD, pin 4
(0066) #define PALE        5   // PORTD, pin 5
(0067) #define DIO         1   // PORTD, pin 1
(0068) #define DCLK        2   // PORTD, pin 2
(0069) 
(0070) #define CAL_TIMEOUT   0x7FFE
(0071) //0x9C40   
(0072) #define LOCK_TIMEOUT  0x7FFE
(0073) //0xC0
(0074) //原先为0x7FFE
(0075) /* Contents of CURRENT register for TX and RX, use SmartRF(R) Studio */
(0076) /* to find values for your application */   
(0077)  
(0078) #define TX_CURRENT 0xF3
(0079) #define RX_CURRENT 0x8C
(0080) 
(0081) /* Contents of PLL register for TX and RX, use SmartRF(R) Studio */
(0082) /* to find values for your application */
(0083) 
(0084) #define TX_PLL 0x18
(0085) #define RX_PLL 0x18
(0086) 
(0087) #define PA_VALUE 0xF0  
(0088) ///????0x90
(0089) 
(0090) 
(0091) 
(0092) /////////////////////////////XIAO YU 修改/////////////////////////
(0093) void delaycc(int t)
(0094)      {
(0095) 	  int i,j;
(0096) 	  for(i = 0;i < t;i++)
    0084 2744      CLR	R20
    0085 2755      CLR	R21
    0086 C00A      RJMP	0x0091
(0097) 	    for(j = 0;j < t;j++);
    0087 2766      CLR	R22
    0088 2777      CLR	R23
    0089 C002      RJMP	0x008C
    008A 5F6F      SUBI	R22,0xFF
    008B 4F7F      SBCI	R23,0xFF
    008C 1760      CP	R22,R16
    008D 0771      CPC	R23,R17
    008E F3DC      BLT	0x008A
    008F 5F4F      SUBI	R20,0xFF
    0090 4F5F      SBCI	R21,0xFF
    0091 1740      CP	R20,R16
    0092 0751      CPC	R21,R17
    0093 F39C      BLT	0x0087
    0094 940E0391  CALL	pop_gset2
    0096 9508      RET
_ConfigureCC1000:
  WordCounter          --> R20
  BitCounter           --> R10
  Data                 --> R22
  Configuration        --> R18
  Count                --> R16
    0097 940E039B  CALL	push_gset3
(0098) 	 }
(0099) 	/////////////// ////////////////////////////////////////////stdio.h
(0100) /****************************************************************************//////////////////////原始的CONFIG
(0101) /*  This routine sends new configuration data to the CC1000                 */
(0102) /*  Based on bit bashing (general I/O pin use)                              */
(0103) /****************************************************************************/
(0104) 
(0105) void ConfigureCC1000(char Count, short Configuration[])
(0106) {
(0107)   char  BitCounter;
(0108)   char  WordCounter;
(0109)   short Data;
(0110)  
(0111)  
(0112)    
(0113)   PORTD|=(1<<PALE); //PALE=1
    0099 9A95      SBI	0x12,5
(0114)   
(0115)   for (WordCounter=0;WordCounter<Count;WordCounter++)
    009A 2744      CLR	R20
    009B C02F      RJMP	0x00CB
(0116)   {
(0117)     Data=Configuration[WordCounter];
    009C E082      LDI	R24,2
    009D 9F84      MUL	R24,R20
    009E 01F0      MOVW	R30,R0
    009F 0FE2      ADD	R30,R18
    00A0 1FF3      ADC	R31,R19
    00A1 8160      LDD	R22,Z+0
    00A2 8171      LDD	R23,Z+1
(0118)     PORTD&=~(1<<PALE); // PALE=0
    00A3 9895      CBI	0x12,5
(0119)     
(0120)     /* Send address bits */
(0121)   for (BitCounter=0;BitCounter<7;BitCounter++)
    00A4 24AA      CLR	R10
    00A5 C00A      RJMP	0x00B0
(0122)     {
(0123)       PORTD|=(1<<PCLK); // PCLK=1
    00A6 9A94      SBI	0x12,4
(0124)       if ((Data&0x8000)==0) {
    00A7 FD77      SBRC	R23,7
    00A8 C002      RJMP	0x00AB
(0125)         PORTD&=~(1<<PDATA); // PDATA=0
    00A9 9893      CBI	0x12,3
(0126)       }
    00AA C001      RJMP	0x00AC
(0127)       else {
(0128)         PORTD|=(1<<PDATA); // PDATA=1
    00AB 9A93      SBI	0x12,3
(0129)       }
(0130)       Data=Data<<1;
    00AC 0F66      LSL	R22
    00AD 1F77      ROL	R23
(0131)       PORTD&=~(1<<PCLK); //PCLK=0;
    00AE 9894      CBI	0x12,4
    00AF 94A3      INC	R10
    00B0 2D8A      MOV	R24,R10
    00B1 3087      CPI	R24,7
    00B2 F398      BCS	0x00A6
(0132)     }
(0133)     
(0134)     /* Send read/write bit */
(0135)     /* Ignore bit in data, always use 1 */
(0136)     
(0137)     PORTD|=(1<<PCLK); //PCLK=1
    00B3 9A94      SBI	0x12,4
(0138)     PORTD|=(1<<PDATA);  //PDATA=1
    00B4 9A93      SBI	0x12,3
(0139)     PORTD&=~(1<<PCLK); //PCLK=0
    00B5 9894      CBI	0x12,4
(0140)     Data=Data<<1;
    00B6 0F66      LSL	R22
    00B7 1F77      ROL	R23
(0141)     PORTD|=(1<<PCLK); //PCLK=1
    00B8 9A94      SBI	0x12,4
(0142)     PORTD|=(1<<PALE); //PALE=1
    00B9 9A95      SBI	0x12,5
(0143)     
(0144)     /* Send data bits */
(0145)     
(0146)     for (BitCounter=0;BitCounter<8;BitCounter++)
    00BA 24AA      CLR	R10
    00BB C00A      RJMP	0x00C6
(0147)     {
(0148)       PORTD|=(1<<PCLK); //PCLK=1
    00BC 9A94      SBI	0x12,4
(0149)       if ((Data&0x8000)==0) {
    00BD FD77      SBRC	R23,7
    00BE C002      RJMP	0x00C1
(0150)         PORTD&=~(1<<PDATA); // PDATA=0
    00BF 9893      CBI	0x12,3
(0151)       }
    00C0 C001      RJMP	0x00C2
(0152)       else {
(0153)         PORTD|=(1<<PDATA); // PDATA=1
    00C1 9A93      SBI	0x12,3
(0154)       }
(0155)       Data=Data<<1;
    00C2 0F66      LSL	R22
    00C3 1F77      ROL	R23
(0156)       PORTD&=~(1<<PCLK); //PCLK=0
    00C4 9894      CBI	0x12,4
    00C5 94A3      INC	R10
    00C6 2D8A      MOV	R24,R10
    00C7 3088      CPI	R24,0x8
    00C8 F398      BCS	0x00BC
(0157)      }
(0158)   PORTD|=(1<<PCLK); //PCLK=1
    00C9 9A94      SBI	0x12,4
    00CA 9543      INC	R20
    00CB 1740      CP	R20,R16
    00CC F278      BCS	0x009C
    00CD 940E0394  CALL	pop_gset3
    00CF 9508      RET
_WriteToCC1000Register:
  val                  --> Y+0
  data                 --> R20
  addr                 --> R22
    00D0 940E039D  CALL	push_gset2
    00D2 2F42      MOV	R20,R18
    00D3 2F60      MOV	R22,R16
    00D4 9722      SBIW	R28,2
(0159)   }   /* Finished with word */   
(0160) }
(0161) 
(0162) /****************************************************************************//////////////////////新的CONFIG
(0163) /*  This routine sends new configuration data to the CC1000                 */
(0164) /*  Based on bit bashing (general I/O pin use)                              */
(0165) /****************************************************************************/
(0166) /*
(0167) void ConfigureCC1000(char Count, short Configuration[])
(0168) {
(0169)   char  BitCounter;
(0170)   char  WordCounter;
(0171)   short Data;
(0172)  
(0173)  
(0174)    
(0175)   PORTA|=(1<<PALE); //PALE=1
(0176)   
(0177)   for (WordCounter=0;WordCounter<Count;WordCounter++)
(0178)   {
(0179)     Data=Configuration[WordCounter];
(0180)     PORTA&=~(1<<PALE); // PALE=0
(0181)     
(0182)     /* Send address bits */
(0183) /*    for (BitCounter=0;BitCounter<7;BitCounter++)
(0184)     {
(0185)       PORTB|=(1<<PCLK); // PCLK=1
(0186)       if ((Data&0x8000)==0) {
(0187)         PORTB&=~(1<<PDATA); // PDATA=0
(0188)       }
(0189)       else {
(0190)         PORTB|=(1<<PDATA); // PDATA=1
(0191)       }
(0192)       Data=Data<<1;
(0193)       PORTB&=~(1<<PCLK); //PCLK=0;
(0194)     }
(0195)     
(0196)     /* Send read/write bit */
(0197)     /* Ignore bit in data, always use 1 */
(0198)  /*    
(0199)     PORTB|=(1<<PCLK); //PCLK=1
(0200)     PORTB|=(1<<PDATA);  //PDATA=1
(0201)     PORTB&=~(1<<PCLK); //PCLK=0
(0202)     Data=Data<<1;
(0203)     PORTB|=(1<<PCLK); //PCLK=1
(0204)     PORTA|=(1<<PALE); //PALE=1
(0205)     
(0206)     /* Send data bits */
(0207)  /*    
(0208)     for (BitCounter=0;BitCounter<8;BitCounter++)
(0209)     {
(0210)       PORTB|=(1<<PCLK); //PCLK=1
(0211)       if ((Data&0x8000)==0) {
(0212)         PORTB&=~(1<<PDATA); // PDATA=0
(0213)       }
(0214)       else {
(0215)         PORTB|=(1<<PDATA); // PDATA=1
(0216)       }
(0217)       Data=Data<<1;
(0218)       PORTB&=~(1<<PCLK); //PCLK=0
(0219)      }
(0220)   PORTB|=(1<<PCLK); //PCLK=1
(0221)   }   /* Finished with word */   
(0222) /* }
(0223) /****************************************************************************/
(0224) /*  This routine writes to a single CC1000 register                         */
(0225) /****************************************************************************/
(0226) 
(0227) void WriteToCC1000Register(char addr, char data)

⌨️ 快捷键说明

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