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

📄 f34x_uart0_interrupt.lst

📁 8051f340实现cc1100软件SPI的正常数据收发
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   F34X_UART0_INTERRUPT                                                  02/03/2009 16:53:57 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE F34X_UART0_INTERRUPT
OBJECT MODULE PLACED IN F34x_UART0_Interrupt.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE F34x_UART0_Interrupt.c BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          //-----------------------------------------------------------------------------
   2          // F34x_UART0_Interrupt.c
   3          //-----------------------------------------------------------------------------
   4          // Copyright 2006 Silicon Laboratories, Inc.
   5          // http://www.silabs.com
   6          //
   7          // Program Description:
   8          //
   9          // This program demonstrates how to configure the C8051F340 to write to and read
  10          // from the UART interface. The program reads a word using the UART interrupts
  11          // and outputs that word to the screen, with all characters in uppercase
  12          //
  13          // How To Test:
  14          //
  15          // 1) Ensure that jumpers are placed on J12 of the C8051F340 target board
  16          //    that connect the P0.4 pin to the TX signal, and P0.5 to the RX signal.
  17          // 2) Ensure that the serial cable is connected to the RS232 connector
  18          //    on the target board.
  19          // 3) Specify the target baudrate in the constant <BAUDRATE>.
  20          // 4) Open Hyperterminal, or a similar program, and connect to the target
  21          //    board's serial port.
  22          // 5) Download and execute code on an 'F34x target board.
  23          // 6) Type up to 64 characters into the Terminal and press Enter.  The MCU 
  24          //    will then print back the characters that were typed
  25          //
  26          // Target:         C8051F34x
  27          // Tool chain:     Keil C51 7.50 / Keil EVAL C51
  28          // Command Line:   None
  29          //
  30          // Release 1.0
  31          //    -Initial Revision (SM)
  32          //    -5 JUN 2007
  33          //
  34          
  35          
  36          //-----------------------------------------------------------------------------
  37          // Includes
  38          //-----------------------------------------------------------------------------
  39          
  40          #include "include.h"
  41          
  42          //-----------------------------------------------------------------------------
  43          // Global CONSTANTS
  44          //-----------------------------------------------------------------------------
  45          
  46          #define SYSCLK      12000000           // SYSCLK frequency in Hz
  47          #define BAUDRATE        9600           // Baud rate of UART in bps
  48          //#define unsigned int    uint;
  49          /*cc1100*/
  50          char paTable[8] = {0x17,0x1c,0x26,0x57,0x60,0x85,0xc8,0xc0};//cc1100对应功率值-20,-15,-10,-5,0,5,7,1
             -0
  51          //char paTable[] = {0x97,0x6e,0x7f,0x97,0xa9,0xbb,0xfe,0xff,};//cc2500对应功率值-10,-8,-6,-4,-2,0,1
  52          char paTableLen = 4;                                         //对应功率值,默认4则为0dbm发送
  53          
  54          char txBuffer[14]={59,1,3,4,5,6,7,8,9,4,5,5,6,2};
C51 COMPILER V7.06   F34X_UART0_INTERRUPT                                                  02/03/2009 16:53:57 PAGE 2   

  55          char rxBuffer[5];
  56          char delay=1;
  57          unsigned char send_num=0;
  58          unsigned char iii;
  59          //函数声明
  60          void  LCDinit(void);
  61          void  TimerSet(void);
  62          void  glit_light( unsigned int delay);
  63          void delay1(unsigned int i);
  64          
  65          //-----------------------------------------------------------------------------
  66          // Function PROTOTYPES
  67          //-----------------------------------------------------------------------------
  68          
  69          void SYSCLK_Init (void);
  70          void UART0_Init (void);
  71          void PORT_Init (void);
  72          void Timer2_Init (int);
  73          
  74          //-----------------------------------------------------------------------------
  75          // Global Variables
  76          //-----------------------------------------------------------------------------
  77          
  78          #define UART_BUFFERSIZE 10
  79          unsigned char UART_Buffer[UART_BUFFERSIZE];
  80          unsigned char UART_Buffer_Size = 0;
  81          unsigned char UART_Input_First = 0;
  82          unsigned char UART_Output_First = 0;
  83          unsigned char TX_Ready =1;
  84          static char Byte;
  85          
  86          //-----------------------------------------------------------------------------
  87          // MAIN Routine
  88          //-----------------------------------------------------------------------------
  89          
  90          void delay1(unsigned int i)
  91          {
  92   1        unsigned int j;
  93   1       for(j=0;j<i;j++)
  94   1       {
  95   2      //  NOP();
  96   2       //_NOP();
  97   2       //_NOP();
  98   2       }
  99   1      
 100   1      
 101   1      }
 102          void main (void)
 103          {
 104   1      
 105   1         PCA0MD &= ~0x40;                    // WDTE = 0 (clear watchdog timer
 106   1                                             // enable)
 107   1         PORT_Init();                        // Initialize Port I/O
 108   1         SYSCLK_Init ();                     // Initialize Oscillator
 109   1         UART0_Init();
 110   1      
 111   1         EA = 1;
 112   1      
 113   1         TI_CC_SPISetup();                                 // spi设置初始化
 114   1          TI_CC_PowerupResetCCxxxx();                       // 复位RF 
 115   1          writeRFSettings();                                // 写RF配置信息
 116   1          
C51 COMPILER V7.06   F34X_UART0_INTERRUPT                                                  02/03/2009 16:53:57 PAGE 3   

 117   1          //SPI验证用于测试无线模块是否连接(工作)正常
 118   1         // txBuffer[63]= TI_CC_SPIReadReg(TI_CCxxx0_IOCFG2); //如果不等于0x06为错误
 119   1         // txBuffer[63]= TI_CC_SPIReadReg(TI_CCxxx0_IOCFG0); //如果不等于0x06为错误   
 120   1          txBuffer[3]= TI_CC_SPIReadReg(0x08);   //如果不等于0x00为错误
 121   1          //输出功率设置    
 122   1          TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, &paTable[paTableLen], 1);
 123   1                                                            //配置发送功率        
 124   1       delay1(50000);
 125   1      //  TI_CC_GDO0_PxIES |= 0X02;       // Int on falling edge (end of pkt)
 126   1       // TI_CC_GDO0_PxIES &= ~TI_CC_GDO0_PIN;
 127   1        //address_bind=TI_CC_SPIReadReg(3);
 128   1       // P1OUT=0x02;//输入上拉
 129   1       // TI_CC_GDO0_PxIFG &= ~0X02;      // Clear flag
 130   1      //  TI_CC_GDO0_PxIE |= 0X02;        // Enable int on end of packet
 131   1      //  P1REN|=0X02;
 132   1         
 133   1      //    _EINT();
 134   1        //   _BIS_SR(GIE);
 135   1          txBuffer[1] = 0x01;
 136   1          while(1)
 137   1          {    
 138   2           //  WDTCTL=WDT_ARST_1000;
 139   2            /* TI_CC_LED_PxOUT ^=TI_CC_LED1;
 140   2             send_num++;                                   //发送数据个数累加
 141   2             TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);             //进入IDLE模式
 142   2             txBuffer[0] =6;                              // Packet length
 143   2             if(txBuffer[1] == 0x02)
 144   2             txBuffer[1] = 0x01;                           // Packet address
 145   2             else if(txBuffer[1] == 0x01)
 146   2             txBuffer[1] = 0x02;                           // Packet address
 147   2             txBuffer[3] = send_num;                       //写入当前发送数据个数
 148   2             RFSendPacket(txBuffer, 7);                   // 发送数据
 149   2                    
 150   2            // TimerSet();                                   //设置TimerA定时器--定时大约一秒
 151   2          //   TI_CC_SPIStrobe(TI_CCxxx0_SPWD);             //进入IDLE模式
 152   2         //    WDTCTL=WDT_ARST_1000;
 153   2            // TI_CC_LED_PxOUT ^=TI_CC_LED1;
 154   2      //       LPM3;  
 155   2         delay1(50000);  */
 156   2         // If the complete word has been entered via the terminal followed by
 157   2            // carriage return
 158   2              //      SBUF0 = 0XDD;
 159   2              //      TI0=1;
 160   2              /*                 while(RI0==0);
 161   2                         txBuffer[1] =SBUF0;
 162   2                      RI0=0;
 163   2                         
 164   2                  if(txBuffer[1] !='\0')  
 165   2                          {    
 166   2                      SBUF0=txBuffer[1] ;
 167   2      
 168   2                              while(TI0==0);
 169   2                              TI0=0;
 170   2                              txBuffer[1] ='\0';
 171   2                              }*/
 172   2              //      delay1(10000);
 173   2        ///    if(TX_Ready == 1 && UART_Buffer_Size != 0 && Byte == 13)
 174   2           // {
 175   2           //    TX_Ready = 0;                 // Set the flag to zero
 176   2           //    TI0 = 1;                      // Set transmit flag to 1
 177   2         //   }
 178   2          }    

⌨️ 快捷键说明

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