C51 COMPILER V9.52.0.0   UARTINIT                                                          10/08/2018 13:51:26 PAGE 1   


C51 COMPILER V9.52.0.0, COMPILATION OF MODULE UARTINIT
OBJECT MODULE PLACED IN .\Output\UARTInit.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\User\Source\Hardware\UARTInit.c LARGE OMF2 WARNINGLEVEL(0) BROWSE INCDIR
                    -(..\Library\FU68xx_Hardware_Driver\Include;..\User\Include) DEBUG PRINT(.\Listing\UARTInit.lst) TABS(2) OBJECT(.\Output\
                    -UARTInit.obj)

line level    source

   1          /**************************** (C) COPYRIGHT 2017 Fortiortech shenzhen *****************************
   2          * File Name          : UARTInit.c
   3          * Author             : Vina Peng,Fortiortech  Appliction Team
   4          * Version            : V1.0
   5          * Date               : 10-Apr-2017
   6          * Description        : This file contains UART initial function used for Motor Control.
   7          ***************************************************************************************************
   8          * All Rights Reserved
   9          **************************************************************************************************/
  10          #include <FU68xx_2.h>
  11          #include <Myproject.h>
  12          /* Private variables ----------------------------------------------------------------------------*/
  13          MCUART Uart;
  14          
  15          void UART_Init(void)
  16          {
  17   1          P0_OE |= P05;
  18   1          P0_PU |= P05;  
  19   1          P0_OE &= ~P06;
  20   1          P0_PU |= P06;   
  21   1          SetBit(PH_SEL, UARTEN);     //使能串口
  22   1          ClrBit(PH_SEL, UARTCH);     //ClrBit(PH_SEL, UARTCH)p0[6]as UART_RXD,p0[5]as UART_TXD;SetBit(PH_SEL, UAR
             -TCH)p3[3]as UART_RXD,p3[4]as UART_TXD;
  23   1          UT_MOD1 = 0;
  24   1          UT_MOD0 = 1;                //MODE1:8bit波特率可变UART模式
  25   1          SM2 = 0;                    //禁止Mode2和Mode3多机通讯
  26   1          REN = 1;                    //使能接收
  27   1          ES0 = 0;                    //先关中断
  28   1          PUART1=0;                   //中断优先级时最低
  29   1          PUART0=0;
  30   1          UT_BAUD =0x9b;              //  波特率=fcpu_clk/((16/(1+UT_BAUD[BAUD_SEL]))*(UT_BAUD+1))； UT_BAUD[B
             -AUD_SEL]为UT_BAUD.15 ;default baudrate:9600-0x9b,4800-0x137;2400-0x270;1200-0x4E1
  31   1      //   fcpu_clk/((16/(1+UT_BAUD[BAUD_SEL]))*(UT_BAUD+1));
  32   1          ES0 = 1;                    //ES0 发送/接受中断使能位
  33   1        EA=1;
  34   1          Uart.R_DATA[0]                     = 0;
  35   1        Uart.R_DATA[1]                     = 0;
  36   1        Uart.R_DATA[2]                     = 0;
  37   1        Uart.R_DATA[3]                     = 0;
  38   1        Uart.R_DATA[4]                     = 0; 
  39   1        Uart.R_DATA[5]                     = 0;
  40   1        Uart.R_DATA[6]                     = 0;
  41   1        Uart.R_DATA[7]                     = 0;
  42   1        Uart.R_DATA[8]                     = 0; 
  43   1        Uart.R_DATA[9]                     = 0;
  44   1        
  45   1        /**·¢ËÍµÄÊý×é******/
  46   1        Uart.T_DATA[0]                     = 0;
  47   1        Uart.T_DATA[1]                     = 0;
  48   1        Uart.T_DATA[2]                     = 0;
  49   1        Uart.T_DATA[3]                     = 0;
  50   1        Uart.T_DATA[4]                     = 0; 
  51   1        Uart.T_DATA[5]                     = 0;
C51 COMPILER V9.52.0.0   UARTINIT                                                          10/08/2018 13:51:26 PAGE 2   

  52   1        Uart.T_DATA[6]                     = 0;
  53   1        Uart.T_DATA[7]                     = 0;
  54   1        Uart.T_DATA[8]                     = 0; 
  55   1        Uart.T_DATA[9]                     = 0;
  56   1        
  57   1        Uart.Uredata                       = 0;
  58   1        Uart.UARxCnt                       = 0;
  59   1        Uart.RxFSM                         = 0;
  60   1        Uart.UsaRxLen                      = 0;
  61   1        Uart.flagUsaRxComm                 = 0;
  62   1        Uart.CheckDate                     = 0;
  63   1        Uart.ResponceCount                 = 0;
  64   1        Uart.ResponceFlag                  = 0;
  65   1        Uart.UsaTxlen                      = 0;
  66   1        Uart.SendCnt                       = 0;
  67   1        
  68   1        
  69   1      #if 0
                  SetBit(PH_SEL, UARTEN);     //p0[6]as UART_RXD; p0[5]as UART_TXD
                  UT_MOD1 = 0;
                  UT_MOD0 = 1;                //8bit波特率可变UART模式
                  SM2 = 0;                    //禁止Mode2和Mode3多机通讯
                  REN = 1;                    //使能接收
                  ES0 = 0;                    //先关中断
              
                  PUART1=0;                   //中断优先级时最低
                  PUART0=0;
              
                  UT_BAUD =0x4E1;              //default baudrate:9600-0x9b,1200-0x4E1
                  ES0 = 1;                    //发送/接受中断使能
                    #endif
  83   1      }
  84          void UartTxdate(uint16* sndBuf, int32 len)
  85          {
  86   1          uint16 i=0;
  87   1        for(i=0;i<len;i++)
  88   1          {
  89   2            UART_SendData(*sndBuf++);
  90   2          }
  91   1      }
  92          void UART_SendData(unsigned char T_Data)
  93          {
  94   1          UT_DR = T_Data;                //发送完成中断标志位清零
  95   1      }
  96          /***************处理串口接收到的数据************/
  97          void UartDealResponse(void)
  98           {
  99   1          
 100   1       }
 101          void UartDealComm(void)
 102          {
 103   1           uint16 j=0;
 104   1           uint16 checkdate=0x00;
 105   1           if(Uart.ResponceFlag==1)//10ms
 106   1           {
 107   2               UartDealResponse();
 108   2               Uart.T_DATA[0]     = 0xaa;
 109   2               Uart.T_DATA[1]     = 0x00;
 110   2               Uart.T_DATA[2]     = 1;// actual speed/16 ,if actual speed=1000rpm/min,then TxBuf[2]=63
 111   2               Uart.T_DATA[3]     = 2;// DC bus feedback, 1 stand for 2V
 112   2               Uart.T_DATA[4]     = 3;//Fault state
 113   2               Uart.T_DATA[5]     = 0x00;
C51 COMPILER V9.52.0.0   UARTINIT                                                          10/08/2018 13:51:26 PAGE 3   

 114   2               Uart.T_DATA[6]     = 0x00;
 115   2               Uart.T_DATA[7]     = 0x00;
 116   2               for( j = 0; j < 7; j++ )
 117   2               {
 118   3                checkdate += Uart.T_DATA[j];
 119   3               }
 120   2               Uart.T_DATA[8]     = checkdate;
 121   2               Uart.T_DATA[9]     = 0x55;
 122   2                Uart.UsaTxlen =9;
 123   2                Uart.SendCnt=0;
 124   2                UART_SendData(Uart.T_DATA[0]);   
 125   2                Uart.ResponceFlag=0;
 126   2           }
 127   1      }
 128          
 129          static uint8 uartRdata[10]; 
 130          static uint8 uartRecCnt = 0;
 131          
 132          static uint8 uartSenddata[10]; 
 133          static uint8 uartSendCnt = 0;
 134          
 135          
 136          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    419    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =     81       9
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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