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

📄 ad9835.lst

📁 DDS数字信号发生器,采用AD9835DDS 专用芯片 输出范围1K--10MHZ 采用X25045作看门狗及数据存储器
💻 LST
字号:
C51 COMPILER V6.02  AD9835                                                                 09/11/2005 06:36:51 PAGE 1   


C51 COMPILER V6.02, COMPILATION OF MODULE AD9835
OBJECT MODULE PLACED IN .\AD9835.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE .\AD9835.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //use uart , mode 1, send
   2          #define IN_SPICommu
   3          #include "SPICommunication.h"
   4          
   5          unsigned char daoUChar(unsigned char uc)
   6          {
   7   1      	unsigned char i, temChar;
   8   1      
   9   1      	temChar = 0;
  10   1      	for( i=0; i<8; i++ ){
  11   2      		temChar = temChar<<1;
  12   2      		if( uc & 0x01 )
  13   2      			temChar += 1;
  14   2      		uc = uc>>1;
  15   2      	}
  16   1      	return temChar;
  17   1      }
  18          
  19          void write2Byte(unsigned char uc1, unsigned char uc2)
  20          {
  21   1      	uc1 = daoUChar(uc1);
  22   1      	uc2 = daoUChar(uc2);
  23   1      
  24   1      	SPI_SS = 0;
  25   1      	 
  26   1       	SBUF = uc1;
  27   1      	while( !TI );
  28   1      	TI = 0;
  29   1      
  30   1       	SBUF = uc2;
  31   1      	while( !TI );
  32   1      	SPI_SS = 1;
  33   1      
  34   1      	TI = 0;
  35   1      }
  36          
  37          void testAD9875(unsigned long writedata);
  38          void writeControl_1(unsigned char i)
  39          {
  40   1      	unsigned char firstByte;
  41   1      	if( i )
  42   1      		firstByte = 0xF8;// sleep,reset,clr
  43   1      	else
  44   1      		firstByte = 0xc0;
  45   1      	write2Byte(firstByte, 0);
  46   1      }
  47          
  48          void writeControl_0()
  49          {
  50   1      	unsigned char firstByte;
  51   1      	firstByte = 0xa0;// set sync and selsrc
  52   1      	write2Byte(firstByte, 0);
  53   1      }
  54          void writeFreReg(unsigned long dat, unsigned char whichFre)
  55          {
C51 COMPILER V6.02  AD9835                                                                 09/11/2005 06:36:51 PAGE 2   

  56   1      	unsigned char byte, baseAddr;
  57   1      	if( whichFre==1 )
  58   1      		baseAddr = 4;
  59   1      	else
  60   1      		baseAddr = 0;
  61   1      		
  62   1      	byte = (dat>>24) & 0xFF;
  63   1      	write2Byte(0x30+baseAddr+0x03, byte);
  64   1      	byte = (dat>>16) & 0xFF;
  65   1      	write2Byte(0x20+baseAddr+0x02, byte);
  66   1      
  67   1      	byte = (dat>>8) & 0xFF;
  68   1      	write2Byte(0x30+baseAddr+0x01, byte);
  69   1      	byte = dat & 0xFF;
  70   1      	write2Byte(0x20+baseAddr+0x00, byte);
  71   1      }
  72          
  73          void writePhase(unsigned int dat, unsigned char whichFre)
  74          {
  75   1      	unsigned char byte, baseAddr;
  76   1      	if( whichFre==0 )
  77   1      		baseAddr = 8;
  78   1      	else if( whichFre==1 ){
  79   2      		baseAddr = 10;
  80   2      	}
  81   1      	else if( whichFre==2 ){
  82   2      		baseAddr = 12;
  83   2      	}
  84   1      	else
  85   1      		baseAddr = 14;
  86   1      
  87   1      	byte = (dat>>8) & 0xFF;
  88   1      	write2Byte(0x10+baseAddr+0x01, byte);
  89   1      	byte = dat & 0xFF;
  90   1      	write2Byte(0x00+baseAddr+0x00, byte);
  91   1      }
  92          
  93          
  94          void testAD9875(unsigned long writedata)
  95          {
  96   1      	unsigned long longData;
  97   1      	longData = 85.89934592 * writedata + 0.5;
  98   1      
  99   1      	writeControl_1(1);
 100   1      	writeControl_0();
 101   1      
 102   1      	writeFreReg(longData, 0);
 103   1      	writeFreReg(0, 1);
 104   1      	writePhase(0x0400, 0);
 105   1      	writePhase(0, 1);
 106   1      	writePhase(0x0c00, 2);
 107   1      	writePhase(0, 3);
 108   1      
 109   1      	writeControl_1(0);
 110   1      }
 111          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    347    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
C51 COMPILER V6.02  AD9835                                                                 09/11/2005 06:36:51 PAGE 3   

   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----      11
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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