C51 COMPILER V9.54   MAIN                                                                  05/19/2022 10:31:24 PAGE 1   


C51 COMPILER V9.54, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Objects\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE source\main.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND PRINT(.\Listin
                    -gs\main.lst) TABS(2) OBJECT(.\Objects\main.obj)

line level    source

   1          /******************** (C) COPYRIGHT 2020 SONiX *******************************
   2          * COMPANY:  SONiX
   3          * DATE:     2022/04
   4          * AUTHOR:   Eden
   5          * IC:       
   6          * DESCRIPTION:
   7          *
   8          *   This sample code demonstrates how to use the UART function.
   9          *
  10          *____________________________________________________________________________
  11          * REVISION  Date        User  Description
  12          * 1.0       2022/04/28  Eden   First release
  13          *
  14          *____________________________________________________________________________
  15          * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  16          * WITH CODING INFORMATION REGARDING THEIR PRODUCTS TIME TO MARKET.
  17          * SONiX SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL 
  18          * DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT OF SUCH SOFTWARE
  19          * AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN 
  20          * IN CONNECTION WITH THEIR PRODUCTS.
  21          *****************************************************************************/
  22          #define __XRAM_SFR_H__
  23          /*_____ I N C L U D E S ____________________________________________________*/
  24          #include <SN8F5835.h>
  25          #include <stdlib.h>
  26          #include "uart.h"
  27          #include "crc.h"
  28          /*_____ D E F I N I T I O N S ______________________________________________*/
  29          
  30          /*_____ D E C L A R A T I O N S ____________________________________________*/
  31          typedef struct{
  32            uint8_t  baryBuf[8];
  33            uint16_t dbCRC16;
  34          }UartData_st;
  35          
  36          UartData_st stUART_Tx;
  37          UartData_st stUART_Rx;
  38          uint16_t  dbCRC16_Calculation;
  39          /*_____ F U N C T I O N S __________________________________________________*/
  40          void GPIO_Initialization(void);
  41          void UART_SettingTxBuf(uint8_t bData, uint8_t bLength); 
  42          /*_____ M A C R O S _________________________________________________________*/
  43          #define IO_PORT0_OUTPUT_LOW   P0M |= 0xFF;  P0 &= 0x00;
  44          #define IO_PORT1_OUTPUT_LOW   P1M |= 0xFF;  P1 &= 0x00;
  45          #define IO_PORT3_OUTPUT_LOW   P3M |= 0xFF;  P3 &= 0x00;
  46          #define IO_PORT4_OUTPUT_LOW   P4M |= 0xFF;  P4 &= 0x00;
  47          
  48          /**
  49            * @brief  Main program: UART Demo Code. Connecting P11 to P07
  50            * @param  : None.
  51            * @retval : None.
  52            */
  53          int main(void)
  54          {
C51 COMPILER V9.54   MAIN                                                                  05/19/2022 10:31:24 PAGE 2   

  55   1        GPIO_Initialization();
  56   1        CRC_Initialization(mskCRCM_POLY_CRC16, mskCRCM_RANGE_3FDD);
  57   1        EAL = 1;
  58   1      
  59   1        /*  UARTn_Init( (1) , (2) , (3) );
  60   1            (1) : "Baud rate selection"
  61   1            (2) : "RX mode: write RX Buf address" 
  62   1                  "TX mode: NULL"
  63   1            (3) : "RX mode: write RX Buf length"  
  64   1                  "TX mode: NULL"                       */
  65   1        
  66   1        UART1_Init(eBAUD_RATE_19200, &stUART_Rx.baryBuf[0], sizeof(stUART_Rx));   
  67   1        UART0_Init(eBAUD_RATE_19200, NULL, NULL);                                   
  68   1        UART2_Init(eBAUD_RATE_19200, NULL, NULL);                                 
  69   1        UART_SettingTxBuf(0xA0, sizeof(stUART_Tx.baryBuf));
  70   1        UART0_TransmitData(&stUART_Tx.baryBuf[0], sizeof(stUART_Tx));
  71   1      P00=1;
  72   1      P00=0;
  73   1        while(1)
  74   1        {
  75   2          /* UART2 RX received Data via U2RX INT*/
  76   2          if(UART1_ReceivedDone())
  77   2          {
  78   3      P01=1;
  79   3      P01=0;
  80   3            /*  (1) Calculate CRC16 result from stUART_Rx.baryBuf 
  81   3                (2) Compare RX calculate CRC16 vs. TX.CRC16 */
  82   3            dbCRC16_Calculation = CRC_ExecuteRamByteCalculation(&stUART_Rx.baryBuf[0], sizeof(stUART_Rx.baryBuf)); 
             -/* (1)  */
  83   3            if(stUART_Rx.dbCRC16 == dbCRC16_Calculation)      /* (2) */
  84   3            {
  85   4              UART_SettingTxBuf(0xB0, sizeof(stUART_Tx.baryBuf));
  86   4              UART1_TransmitData(&stUART_Tx.baryBuf[0], sizeof(stUART_Tx)); 
  87   4            } 
  88   3            else 
  89   3            {
  90   4              while(1);   /* Compare CRC16 Error*/
  91   4            }
  92   3          }
  93   2        }
  94   1      }
  95          
  96          /**
  97           *  @Brief    Initialize GPIO status
  98           *  @param    None
  99           *  @retval   None
 100           */
 101          void GPIO_Initialization(void)
 102          {
 103   1        /*  Set whole IOs to output low */
 104   1        IO_PORT0_OUTPUT_LOW
 105   1        IO_PORT1_OUTPUT_LOW
 106   1        IO_PORT3_OUTPUT_LOW
 107   1        IO_PORT4_OUTPUT_LOW
 108   1      }
 109          /**
 110           *  @Brief    Setting Tx Buf
 111           *  @param    bData, bLength
 112           *  @retval   None
 113           */
 114          void UART_SettingTxBuf(uint8_t bData, uint8_t bLength)
 115          {
C51 COMPILER V9.54   MAIN                                                                  05/19/2022 10:31:24 PAGE 3   

 116   1        uint8_t i;
 117   1        for(i=0; i< bLength ; i++)
 118   1        {
 119   2          stUART_Tx.baryBuf[i] = bData +i;
 120   2        }
 121   1        /* Calculate CRC16  */
 122   1        stUART_Tx.dbCRC16 = CRC_ExecuteRamByteCalculation(&stUART_Tx.baryBuf[0], sizeof(stUART_Tx.baryBuf));  
 123   1      }
 124          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    196    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     22    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


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