ANSI-C/cC++ Compiler for ST7 V-5.0.7, Aug 21 2001

    1:  /******************************************************************************
    2:  COPYRIGHT 2002 STMicroelectronics
    3:  Source File Name : sci.c 
    4:  Group            : IPSW,CMG-IPDF
    5:  Author           : MCD Application Team
    6:  Date First Issued: 5/3/2002
    7:  ********************************Documentation**********************************
    8:  General Purpose - Contains source code for all the functions of SCI
    9:  
   10:  ********************************Revision History*******************************
   11:  _______________________________________________________________________________
   12:  Date :5/3/2002            Release:1.0
   13:  Date :16/12/2003        Release:2.0
   14:                          1. Removed register definitions from sci_hr.h
   15:                          2. Added support for ST72561 device         
   16:  Date :28/04/2004        MISRA changes  
   17:  ******************************************************************************/
   18:  
   19:  #include "ST7lib_Config.h"           /*Selection of device,compiler and modes*/
   20:  #include "Sci_hr.h"                        /*SCI HW registers Bit Definitions*/
   21:  #include "Sci.h"                                   /*Declaration of functions*/
   22:  
   23:  unsigned char Pr_Value[4] = { 1, 3, 4,13 };
   24:                                              /*Declaration of Global Variables*/
   25:  static volatile unsigned char SCI_Error;   
   26:  
   27:  #if defined SCI_ITDRV_WITHOUTBUF_RX  
   28:  static volatile unsigned char SCI_MY_DATA;
   29:  static volatile unsigned char *PtrToSCIBuffRx;
   30:  #endif
   31:  #ifdef SCI_ITDRV_WITHOUTBUF_TX 
   32:  static const volatile unsigned char *PtrToSCIBuffTx; 
   33:  #endif
   34:  
   35:  static volatile unsigned char SCI_Tx_Buff;
   36:  static volatile unsigned char SCI_Tx_String;
   37:  static volatile unsigned int SCI_Rx_Buff;
   38:  static volatile unsigned char SCI_Rx_String;
   39:  static volatile unsigned char SCI_Pol_Stat;  
   40:  
   41:  #ifdef SCI_72F561                           
   42:                                              /*Declaration of Global Variables*/
   43:  static volatile unsigned char SCI2_Error;   
   44:  static volatile unsigned char SCI2_MY_DATA;
   45:  static const volatile unsigned char *PtrToSCI2BuffTx; 
   46:  static volatile unsigned char *PtrToSCI2BuffRx;
   47:  static volatile unsigned char SCI2_Tx_Buff;
   48:  static volatile unsigned char SCI2_Tx_String;
   49:  static volatile unsigned int SCI2_Rx_Buff;
   50:  static volatile unsigned char SCI2_Rx_String;
   51:  static volatile unsigned char SCI2_Pol_Stat;
   52:  #endif
   53:  
   54:  /*-----------------------------------------------------------------------------
   55:  ROUTINE NAME : SCI_Init
   56:  INPUT        : 1.SCI_DEFAULT_PARAM1, SCI_WORDLENGTH_9,SCI_ODPARITY_SELECT,
   57:                   SCI_EVPARITY_SELECT or SCI_WAKEUP_ADDR
   58:                 2.SCI_MUTE_ENABLE,SCI_BREAK_ENABLE,SCI_DEFAULT_PARAM2
   59:  OUTPUT       : None              
   60:  DESCRIPTION  : Initializes the SCI in the required mode
   61:  COMMENTS     : Must be called before starting any sci operation
   62:  -----------------------------------------------------------------------------*/
   63:  void SCI_Init ( SCI_Type_Param1  Init_Value1, SCI_Type_Param2  Init_Value2)
   64:  {   

Function: SCI_Init
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 bf00     LD    __OVL_8_SCI_Init_p1,X
  0002 b700     LD    __OVL_8_SCI_Init_p0,A
   65:      unsigned char temp;    
   66:      
   67:      SCICR1 = SCI_DEFAULT_PARAM1;                         /*Load Default value*/
  0004 3f00     CLR   SCICR1
   68:      SCICR2 = SCI_DEFAULT_PARAM2;
  0006 3f00     CLR   SCICR2
   69:      temp = SCISR;                    /*Clear all the flags in Status register*/
  0008 b600     LD    A,SCISR
   70:      temp = SCIDR;
  000a b600     LD    A,SCIDR
   71:      SCIDR = SCI_DEFAULT_PARAM1;
  000c 3f00     CLR   SCIDR
   72:      SCICR1 |= (unsigned char)Init_Value1;/*Sets SCI in the required mode*/
  000e b600     LD    A,SCICR1
  0010 ba00     OR    A,__OVL_8_SCI_Init_p1
  0012 b700     LD    SCICR1,A
   73:      SCICR2 |= (unsigned char)Init_Value2;
  0014 b600     LD    A,SCICR2
  0016 ba00     OR    A,__OVL_8_SCI_Init_p0
  0018 b700     LD    SCICR2,A
   74:      SCI_Pol_Stat = SCI_Error = 0;              /*Initializes global variables*/
  001a 4f       CLR   A
  001b c70000   LD    SCI_Error,A
  001e c60000   LD    A,SCI_Error
  0021 c70000   LD    SCI_Pol_Stat,A
   75:      SCI_Tx_Buff = 0;
  0024 4f       CLR   A
  0025 c70000   LD    SCI_Tx_Buff,A
   76:      SCI_Tx_String = 0;
  0028 c70000   LD    SCI_Tx_String,A
   77:      SCI_Rx_Buff = SCI_Rx_String = 0;         
  002b c70000   LD    SCI_Rx_String,A
  002e c60000   LD    A,SCI_Rx_String
  0031 c70001   LD    SCI_Rx_Buff:1,A
  0034 5f       CLR   X
  0035 cf0000   LD    SCI_Rx_Buff,X
   78:  
   79:  #ifdef SCI_72F561
   80:      SCICR3 = 0x00;
   81:  #endif    
   82:  }        
  0038 81       RET   
   83:  //for SCI2 of 561 device
   84:  #ifdef SCI_72F561
   85:  void SCI2_Init ( SCI_Type_Param1  Init_Value1, SCI_Type_Param2  Init_Value2)
   86:  {   
   87:      unsigned char temp;    
   88:      
   89:      SCI2CR1 = SCI_DEFAULT_PARAM1;                        /*Load Default value*/
   90:      SCI2CR2 = SCI_DEFAULT_PARAM2;
   91:      temp = SCI2SR;                   /*Clear all the flags in Status register*/
   92:      temp = SCI2DR;
   93:      SCI2DR = SCI_DEFAULT_PARAM1;
   94:      SCI2CR1 |= (unsigned char)Init_Value1;    /*Sets SCI in the required mode*/
   95:      SCI2CR2 |= (unsigned char)Init_Value2;
   96:      SCI2_Pol_Stat = SCI2_Error = 0;            /*Initializes global variables*/
   97:      SCI2_Tx_Buff = 0;
   98:      SCI2_Tx_String = 0;
   99:      SCI2_Rx_Buff = SCI2_Rx_String = 0;         
  100:      SCI2CR3 = 0x00;
  101:  }
  102:  #endif
  103:  
  104:  /*-----------------------------------------------------------------------------
  105:  ROUTINE NAME : SCI_Forced_Clear_Flag
  106:  INPUT        : None
  107:  OUTPUT       : None      
  108:  DESCRIPTION  : Clears all status flag performs both read and write operation 
  109:  COMMENTS     : Can be used if clearing of all status flag is needed
  110:  -----------------------------------------------------------------------------*/
  111:  void SCI_Forced_Clear_Flag( void )
  112:  {

Function: SCI_Forced_Clear_Flag
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  113:      unsigned char Temp_Variable,temp;     
  114:      
  115:      Temp_Variable = SCICR2; 
  0000 b600     LD    A,SCICR2
  116:      SCICR2 = 0x00;      
  0002 3f00     CLR   SCICR2
  117:      temp = SCISR;                       /*Clears all flags in status register*/
  0004 be00     LD    X,SCISR
  118:      SCIDR = 0x00; 
  0006 3f00     CLR   SCIDR
  119:      SCICR2 = Temp_Variable;
  0008 b700     LD    SCICR2,A
  120:  }  
  000a 81       RET   
  121:  
  122:  #ifdef SCI_72F561
  123:  void SCI2_Forced_Clear_Flag( void )
  124:  {
  125:      unsigned char Temp_Variable,temp;     
  126:      
  127:      Temp_Variable = SCI2CR2; 
  128:      SCI2CR2 = 0x00;      
  129:      temp = SCI2SR;                      /*Clears all flags in status register*/
  130:      SCI2DR = 0x00; 
  131:      SCI2CR2 = Temp_Variable;
  132:  }                
  133:  #endif
  134:                                                                                 
  135:  /*-----------------------------------------------------------------------------
  136:  ROUTINE NAME : SCI_Compute_Baudrate
  137:  INPUT        : BaudRate_Tx,BaudRate_Rx.
  138:  OUTPUT       : None
  139:  DESCRIPTION  : Selects any possible  baudrate.
  140:  COMMENTS     : User needs to select proper value of function argument.
  141:  -----------------------------------------------------------------------------*/
  142:  /* RBuilder can override this function by adding 
  143:                                              #define REM_SCI_COMPUTE_BAUDRATE */
  144:  #ifndef REM_SCI_COMPUTE_BAUDRATE
  145:  
  146:  void SCI_Compute_Baudrate ( unsigned int BaudRate_Tx, unsigned int BaudRate_Rx)
  147:  {

Function: SCI_Compute_Baudrate
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 b701     LD    __OVL_20_SCI_Compute_Baudrate_p0:1,A
  0002 bf00     LD    __OVL_20_SCI_Compute_Baudrate_p0,X
  148:      unsigned char  Presc_Value,TPR1, TPR2, RPR1, RPR2,i;
  149:      unsigned int  Tx_Value, Rx_Value,temp1;
  150:      unsigned int TR1, TR2, RR1, RR2,Presc_Fact,j,count; 
  151:      unsigned long temp; 
  152:             
  153:      TPR1 = 0;
  0004 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_TPR1
  154:      TPR2 = 0;
  0006 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_TPR2
  155:      RPR1 = 0;
  0008 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_RPR1
  156:      RPR2 = 0; 
  000a 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_RPR2
  157:      temp = 0; 
  000c 3f03     CLR   __OVL_20_SCI_Compute_Baudrate_temp:3
  000e 3f02     CLR   __OVL_20_SCI_Compute_Baudrate_temp:2
  0010 3f01     CLR   __OVL_20_SCI_Compute_Baudrate_temp:1
  158:      
  159:      temp = Fcpu/BaudRate_Tx;                       
  0012 905f     CLR   Y
  0014 9089     PUSH  Y
  0016 a67a     LD    A,#122
  0018 88       PUSH  A
  0019 ae12     LD    X,#18
  001b 89       PUSH  X
  001c 9089     PUSH  Y
  001e 3f00     CLR   _R_Z
  0020 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_p1
  0022 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_p1:1
  0024 cd0000   CALL  _LDIVU
  0027 cd02c1   CALL  SCI_Compute_Baudrate:705
  160:      for (temp1 = 0,count = 1;temp1 < 1;count++)    
  002a 2064     JRT   *102 ;abs = 0090
  161:      {    
  162:          Presc_Fact = ((unsigned int)(temp/16)) ;
  002c cd028c   CALL  SCI_Compute_Baudrate:652
  163:          for (i = 0; i != 4; i++)
  164:          {
  165:              for (j = 1; j <= 128; j = j*2)
  002f cd02e9   CALL  SCI_Compute_Baudrate:745
  166:              {
  167:                  if ( ((Pr_Value[i]*j) == Presc_Fact) && (TPR1 == 0) )
  0032 cd0274   CALL  SCI_Compute_Baudrate:628
  0035 2617     JRNE  *25 ;abs = 004e
  0037 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  0039 2613     JRNE  *21 ;abs = 004e
  003b b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TPR1
  003d 260f     JRNE  *17 ;abs = 004e
  168:                  {
  169:                      TPR1 = Pr_Value[i];     /*Prescalar value for Transmitter*/
  003f cd0304   CALL  SCI_Compute_Baudrate:772
  0042 b700     LD    __OVL_20_SCI_Compute_Baudrate_TPR1,A
  170:                      TR1  = j;                      /*Transmitter rate divisor*/
  0044 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  0046 b701     LD    __OVL_20_SCI_Compute_Baudrate_TR1:1,A
  0048 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  004a b700     LD    __OVL_20_SCI_Compute_Baudrate_TR1,A
  171:                      temp1++;
  172:                  }
  004c 2016     JRT   *24 ;abs = 0064
  173:                  else if ((Pr_Value[i]*j) == Presc_Fact)
  004e cd0274   CALL  SCI_Compute_Baudrate:628
  0051 2617     JRNE  *25 ;abs = 006a
  0053 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  0055 2613     JRNE  *21 ;abs = 006a
  174:                  {
  175:                      TPR2 = Pr_Value[i]; 
  0057 cd0304   CALL  SCI_Compute_Baudrate:772
  005a b700     LD    __OVL_20_SCI_Compute_Baudrate_TPR2,A
  176:                                      /*Another Prescalar value for Transmitter*/
  177:                      TR2 = j;               /*Another Transmitter rate divisor*/
  005c b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  005e b701     LD    __OVL_20_SCI_Compute_Baudrate_TR2:1,A
  0060 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  0062 b700     LD    __OVL_20_SCI_Compute_Baudrate_TR2,A
  178:                      temp1++;
  0064 3c01     INC   __OVL_20_SCI_Compute_Baudrate_temp1:1
  0066 2602     JRNE  *4 ;abs = 006a
  0068 3c00     INC   __OVL_20_SCI_Compute_Baudrate_temp1
  006a cd02e3   CALL  SCI_Compute_Baudrate:739
  006d 25c3     JRULT *-59 ;abs = 0032
  006f 2604     JRNE  *6 ;abs = 0075
  0071 a180     CP    A,#128
  0073 23bd     JRULE *-65 ;abs = 0032
  0075 3c00     INC   __OVL_20_SCI_Compute_Baudrate_i
  0077 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_i
  0079 a104     CP    A,#4
  007b 26b2     JRNE  *-76 ;abs = 002f
  179:                  }
  180:              }
  181:          }   
  182:          if(count%2 == 0)      /*Changes the temp value if no prescalar factor
  007d 000105   BTJT  __OVL_20_SCI_Compute_Baudrate_count:1,#0,*8 ;abs = 0085
  183:                                                                       is found*/
  184:          {         
  185:              temp = temp + count;                           
  0080 cd02ce   CALL  SCI_Compute_Baudrate:718
  186:          }
  0083 2003     JRT   *5 ;abs = 0088
  187:          else
  188:          {         
  189:              temp = temp - count;
  0085 cd02a8   CALL  SCI_Compute_Baudrate:680
  0088 b700     LD    __OVL_20_SCI_Compute_Baudrate_temp,A
  008a 3c01     INC   __OVL_20_SCI_Compute_Baudrate_count:1
  008c 2602     JRNE  *4 ;abs = 0090
  008e 3c00     INC   __OVL_20_SCI_Compute_Baudrate_count
  0090 cd0311   CALL  SCI_Compute_Baudrate:785
  0093 2597     JRULT *-103 ;abs = 002c
  0095 2604     JRNE  *6 ;abs = 009b
  0097 a101     CP    A,#1
  0099 2591     JRULT *-109 ;abs = 002c
  190:          }    
  191:      }               
  192:      temp = Fcpu/BaudRate_Rx; 
  009b 905f     CLR   Y
  009d 9089     PUSH  Y
  009f a67a     LD    A,#122
  00a1 88       PUSH  A
  00a2 ae12     LD    X,#18
  00a4 89       PUSH  X
  00a5 9089     PUSH  Y
  00a7 3f00     CLR   _R_Z
  00a9 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_p0
  00ab b601     LD    A,__OVL_20_SCI_Compute_Baudrate_p0:1
  00ad cd0000   CALL  _LDIVU
  00b0 cd02c1   CALL  SCI_Compute_Baudrate:705
  193:      for (temp1 = 0,count = 1;temp1 < 1;count++)
  00b3 2064     JRT   *102 ;abs = 0119
  194:      {   
  195:          Presc_Fact = (unsigned int)(temp/16); 
  00b5 cd028c   CALL  SCI_Compute_Baudrate:652
  196:          for (i = 0; i != 4; i++)
  197:          {
  198:              for (j = 1; j <= 128; j = j*2)
  00b8 cd02e9   CALL  SCI_Compute_Baudrate:745
  199:              {
  200:                  if (((Pr_Value[i]*j) == Presc_Fact) && (RPR1 == 0))
  00bb cd0274   CALL  SCI_Compute_Baudrate:628
  00be 2617     JRNE  *25 ;abs = 00d7
  00c0 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  00c2 2613     JRNE  *21 ;abs = 00d7
  00c4 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_RPR1
  00c6 260f     JRNE  *17 ;abs = 00d7
  201:                  {
  202:                      RPR1 = Pr_Value[i];        /*Prescalar value for Receiver*/
  00c8 cd0304   CALL  SCI_Compute_Baudrate:772
  00cb b700     LD    __OVL_20_SCI_Compute_Baudrate_RPR1,A
  203:                      RR1    = j;                       /*Receiver rate divisor*/
  00cd b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  00cf b701     LD    __OVL_20_SCI_Compute_Baudrate_RR1:1,A
  00d1 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  00d3 b700     LD    __OVL_20_SCI_Compute_Baudrate_RR1,A
  204:                      temp1++;
  205:                  }
  00d5 2016     JRT   *24 ;abs = 00ed
  206:                  else if ((Pr_Value[i]*j) == Presc_Fact)
  00d7 cd0274   CALL  SCI_Compute_Baudrate:628
  00da 2617     JRNE  *25 ;abs = 00f3
  00dc b101     CP    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  00de 2613     JRNE  *21 ;abs = 00f3
  207:                  {
  208:                      RPR2 = Pr_Value[i];
  00e0 cd0304   CALL  SCI_Compute_Baudrate:772
  00e3 b700     LD    __OVL_20_SCI_Compute_Baudrate_RPR2,A
  209:                                         /*Another Prescalar value for Receiver*/
  210:                      RR2    = j;                /*Another Receiver rate divisor*/
  00e5 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  00e7 b701     LD    __OVL_20_SCI_Compute_Baudrate_RR2:1,A
  00e9 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  00eb b700     LD    __OVL_20_SCI_Compute_Baudrate_RR2,A
  211:                      temp1++;
  00ed 3c01     INC   __OVL_20_SCI_Compute_Baudrate_temp1:1
  00ef 2602     JRNE  *4 ;abs = 00f3
  00f1 3c00     INC   __OVL_20_SCI_Compute_Baudrate_temp1
  00f3 cd02e3   CALL  SCI_Compute_Baudrate:739
  00f6 25c3     JRULT *-59 ;abs = 00bb
  00f8 2604     JRNE  *6 ;abs = 00fe
  00fa a180     CP    A,#128
  00fc 23bd     JRULE *-65 ;abs = 00bb
  00fe 3c00     INC   __OVL_20_SCI_Compute_Baudrate_i
  0100 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_i
  0102 a104     CP    A,#4
  0104 26b2     JRNE  *-76 ;abs = 00b8
  212:                  }
  213:              }
  214:          }
  215:          if(count%2 == 0)
  0106 000105   BTJT  __OVL_20_SCI_Compute_Baudrate_count:1,#0,*8 ;abs = 010e
  216:                       /*Changes the temp value if no prescalar factor is found*/                                                        
  217:          {     
  218:              temp = temp + count;
  0109 cd02ce   CALL  SCI_Compute_Baudrate:718
  219:          }
  010c 2003     JRT   *5 ;abs = 0111
  220:          else
  221:          {     
  222:              temp = temp - count;
  010e cd02a8   CALL  SCI_Compute_Baudrate:680
  0111 b700     LD    __OVL_20_SCI_Compute_Baudrate_temp,A
  0113 3c01     INC   __OVL_20_SCI_Compute_Baudrate_count:1
  0115 2602     JRNE  *4 ;abs = 0119
  0117 3c00     INC   __OVL_20_SCI_Compute_Baudrate_count
  0119 cd0311   CALL  SCI_Compute_Baudrate:785
  011c 2597     JRULT *-103 ;abs = 00b5
  011e 2604     JRNE  *6 ;abs = 0124
  0120 a101     CP    A,#1
  0122 2591     JRULT *-109 ;abs = 00b5
  223:          }
  224:      } 
  225:                  /*Searches common Prescalar factor for transmitter & receiver*/
  226:      if (TPR1 == RPR1)    
  0124 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TPR1
  0126 b100     CP    A,__OVL_20_SCI_Compute_Baudrate_RPR1
  0128 2605     JRNE  *7 ;abs = 012f
  227:      {
  228:          Presc_Value = TPR1;
  012a cd02f0   CALL  SCI_Compute_Baudrate:752
  229:          Tx_Value    = TR1;
  230:          Rx_Value    = RR1;
  231:      }
  012d 2012     JRT   *20 ;abs = 0141
  232:      else if ( TPR1 == RPR2)
  012f b100     CP    A,__OVL_20_SCI_Compute_Baudrate_RPR2
  0131 2605     JRNE  *7 ;abs = 0138
  233:      {
  234:          Presc_Value = TPR1;
  0133 cd02f0   CALL  SCI_Compute_Baudrate:752
  235:          Tx_Value    = TR1;
  236:          Rx_Value    = RR2;
  237:      }
  0136 201c     JRT   *30 ;abs = 0154
  238:      else if ( TPR2 == RPR1)
  0138 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TPR2
  013a b100     CP    A,__OVL_20_SCI_Compute_Baudrate_RPR1
  013c 260f     JRNE  *17 ;abs = 014d
  239:      {
  240:          Presc_Value = TPR2;
  013e cd0318   CALL  SCI_Compute_Baudrate:792
  241:          Tx_Value    = TR2;
  0141 b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value,A
  242:          Rx_Value    = RR1;
  0143 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_RR1:1
  0145 b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1,A
  0147 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_RR1
  0149 b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value,A
  014b 207b     JRT   *125 ;abs = 01c8
  243:      }
  244:      else if ( TPR2 == RPR2)
  014d b100     CP    A,__OVL_20_SCI_Compute_Baudrate_RPR2
  014f 260f     JRNE  *17 ;abs = 0160
  245:      {
  246:          Presc_Value = TPR2;
  0151 cd0318   CALL  SCI_Compute_Baudrate:792
  247:          Tx_Value    = TR2;
  0154 b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value,A
  248:          Rx_Value    = RR2;
  0156 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_RR2:1
  0158 b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1,A
  015a b600     LD    A,__OVL_20_SCI_Compute_Baudrate_RR2
  015c b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value,A
  015e 2068     JRT   *106 ;abs = 01c8
  249:      }   
  250:      else                    /*If no common prescalar division factor is found*/
  251:      {
  252:          for (temp1=0,count=1;temp1<1;count++)
  0160 cd02f9   CALL  SCI_Compute_Baudrate:761
  0163 2058     JRT   *90 ;abs = 01bd
  253:          {
  254:              for (j=1; j<=128; j= j*2)
  0165 cd02e9   CALL  SCI_Compute_Baudrate:745
  255:              {
  256:                  if ( (TPR1*j) == Presc_Fact)
  0168 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_j
  016a 89       PUSH  X
  016b b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  016d 88       PUSH  A
  016e b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TPR1
  0170 5f       CLR   X
  0171 cd0000   CALL  _IMULU
  0174 b300     CP    X,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact
  0176 2619     JRNE  *27 ;abs = 0191
  0178 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  017a 2615     JRNE  *23 ;abs = 0191
  257:                  {
  258:                      Presc_Value = TPR1; 
  017c b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TPR1
  017e cd02f0   CALL  SCI_Compute_Baudrate:752
  259:                      Tx_Value = TR1; 
  0181 b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value,A
  260:                      Rx_Value = j;
  0183 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  0185 b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1,A
  0187 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  0189 b700     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value,A
  261:                      temp1++; 
  018b 3c01     INC   __OVL_20_SCI_Compute_Baudrate_temp1:1
  018d 2602     JRNE  *4 ;abs = 0191
  018f 3c00     INC   __OVL_20_SCI_Compute_Baudrate_temp1
  0191 cd02e3   CALL  SCI_Compute_Baudrate:739
  0194 25d2     JRULT *-44 ;abs = 0168
  0196 2604     JRNE  *6 ;abs = 019c
  0198 a180     CP    A,#128
  019a 23cc     JRULE *-50 ;abs = 0168
  262:                  }
  263:              }
  264:              if(count%2 == 0)
  019c 00010c   BTJT  __OVL_20_SCI_Compute_Baudrate_count:1,#0,*15 ;abs = 01ab
  265:              {     
  266:                  Presc_Fact = Presc_Fact+count;
  019f b601     LD    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  01a1 bb01     ADD   A,__OVL_20_SCI_Compute_Baudrate_count:1
  01a3 b701     LD    __OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1,A
  01a5 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact
  01a7 b900     ADC   A,__OVL_20_SCI_Compute_Baudrate_count
  267:              }
  01a9 200a     JRT   *12 ;abs = 01b5
  268:              else
  269:              {     
  270:                  Presc_Fact = Presc_Fact-count;
  01ab b601     LD    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1
  01ad b001     SUB   A,__OVL_20_SCI_Compute_Baudrate_count:1
  01af b701     LD    __OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1,A
  01b1 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact
  01b3 b200     SBC   A,__OVL_20_SCI_Compute_Baudrate_count
  01b5 b700     LD    __OVL_20_SCI_Compute_Baudrate_10_Presc_Fact,A
  01b7 3c01     INC   __OVL_20_SCI_Compute_Baudrate_count:1
  01b9 2602     JRNE  *4 ;abs = 01bd
  01bb 3c00     INC   __OVL_20_SCI_Compute_Baudrate_count
  01bd cd0311   CALL  SCI_Compute_Baudrate:785
  01c0 25a3     JRULT *-91 ;abs = 0165
  01c2 2604     JRNE  *6 ;abs = 01c8
  01c4 a101     CP    A,#1
  01c6 259d     JRULT *-97 ;abs = 0165
  271:              }
  272:          }
  273:      }    
  274:      if (Presc_Value == 1)
  01c8 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_11_Presc_Value
  01ca a101     CP    A,#1
  01cc 2604     JRNE  *6 ;abs = 01d2
  275:      {
  276:          Presc_Value = 0;
  01ce 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_11_Presc_Value
  277:      }
  01d0 2014     JRT   *22 ;abs = 01e6
  278:      else if (Presc_Value == 3)
  01d2 a103     CP    A,#3
  01d4 2604     JRNE  *6 ;abs = 01da
  279:      {
  280:          Presc_Value = 1;
  01d6 a601     LD    A,#1
  281:      }
  01d8 200a     JRT   *12 ;abs = 01e4
  282:      else if (Presc_Value == 4)
  01da a104     CP    A,#4
  01dc 2604     JRNE  *6 ;abs = 01e2
  283:      {
  284:          Presc_Value = 2;
  01de a602     LD    A,#2
  285:      }
  01e0 2002     JRT   *4 ;abs = 01e4
  286:      else 
  287:      {
  288:          Presc_Value = 3;
  01e2 a603     LD    A,#3
  01e4 b700     LD    __OVL_20_SCI_Compute_Baudrate_11_Presc_Value,A
  289:      }
  290:      for (i=0,j=1; j<=128; j=j*2)
  01e6 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_i
  01e8 cd02e9   CALL  SCI_Compute_Baudrate:745
  01eb 2019     JRT   *27 ;abs = 0206
  291:      {
  292:          if ( j == Tx_Value )
  01ed b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  01ef b100     CP    A,__OVL_20_SCI_Compute_Baudrate_8_Tx_Value
  01f1 260d     JRNE  *15 ;abs = 0200
  01f3 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  01f5 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1
  01f7 2607     JRNE  *9 ;abs = 0200
  293:          {
  294:              Tx_Value = i;
  01f9 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_i
  01fb b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1,A
  01fd 4f       CLR   A
  01fe 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value
  295:          }
  296:          i++;
  0200 3c00     INC   __OVL_20_SCI_Compute_Baudrate_i
  0202 3801     SLL   __OVL_20_SCI_Compute_Baudrate_j:1
  0204 3900     RLC   __OVL_20_SCI_Compute_Baudrate_j
  0206 cd030a   CALL  SCI_Compute_Baudrate:778
  0209 25e2     JRULT *-28 ;abs = 01ed
  020b 2604     JRNE  *6 ;abs = 0211
  020d a180     CP    A,#128
  020f 23dc     JRULE *-34 ;abs = 01ed
  297:      }
  298:      for (i=0,j=1; j<=128; j=j*2)
  0211 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_i
  0213 cd02e9   CALL  SCI_Compute_Baudrate:745
  0216 2019     JRT   *27 ;abs = 0231
  299:      {
  300:      if ( j == Rx_Value )
  0218 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_j
  021a b100     CP    A,__OVL_20_SCI_Compute_Baudrate_8_Rx_Value
  021c 260d     JRNE  *15 ;abs = 022b
  021e b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  0220 b101     CP    A,__OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1
  0222 2607     JRNE  *9 ;abs = 022b
  301:          {    
  302:              Rx_Value = i;
  0224 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_i
  0226 b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1,A
  0228 4f       CLR   A
  0229 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_8_Rx_Value
  303:          }
  304:          i++;
  022b 3c00     INC   __OVL_20_SCI_Compute_Baudrate_i
  022d 3801     SLL   __OVL_20_SCI_Compute_Baudrate_j:1
  022f 3900     RLC   __OVL_20_SCI_Compute_Baudrate_j
  0231 cd030a   CALL  SCI_Compute_Baudrate:778
  0234 25e2     JRULT *-28 ;abs = 0218
  0236 2604     JRNE  *6 ;abs = 023c
  0238 a180     CP    A,#128
  023a 23dc     JRULE *-34 ;abs = 0218
  305:      }  
  306:      Presc_Value <<= 6 ;
  023c ae40     LD    X,#64
  023e b600     LD    A,__OVL_20_SCI_Compute_Baudrate_11_Presc_Value
  0240 42       MUL   X,A
  0241 b700     LD    __OVL_20_SCI_Compute_Baudrate_11_Presc_Value,A
  307:      SCIBRR &= SCI_PR ;  
  0243 b600     LD    A,SCIBRR
  0245 a43f     AND   A,#-193
  0247 b700     LD    SCIBRR,A
  308:      SCIBRR |= Presc_Value ;                             /*Loads the prescalar*/
  0249 b600     LD    A,SCIBRR
  024b ba00     OR    A,__OVL_20_SCI_Compute_Baudrate_11_Presc_Value
  024d b700     LD    SCIBRR,A
  309:  
  310:      Tx_Value <<= 3 ;                     /*Loads the transmitter rate divisor*/
  024f 3801     SLL   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1
  0251 3900     RLC   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value
  0253 3801     SLL   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1
  0255 3900     RLC   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value
  0257 3801     SLL   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1
  0259 3900     RLC   __OVL_20_SCI_Compute_Baudrate_8_Tx_Value
  311:      SCIBRR &= SCI_TR ;
  025b b600     LD    A,SCIBRR
  025d a4c7     AND   A,#-57
  025f b700     LD    SCIBRR,A
  312:      SCIBRR |= (unsigned char)Tx_Value ;
  0261 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1
  0263 ba00     OR    A,SCIBRR
  0265 b700     LD    SCIBRR,A
  313:  
  314:      SCIBRR &= SCI_RR ;                      /*Loads the receiver rate divisor*/
  0267 b600     LD    A,SCIBRR
  0269 a4f8     AND   A,#-8
  026b b700     LD    SCIBRR,A
  315:      SCIBRR |= (unsigned char)Rx_Value ;
  026d b601     LD    A,__OVL_20_SCI_Compute_Baudrate_8_Rx_Value:1
  026f ba00     OR    A,SCIBRR
  0271 b700     LD    SCIBRR,A
  316:  } 
  0273 81       RET   
  0274 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_i
  0276 9093     LD    Y,X
  0278 d60000   LD    A,(Pr_Value,X)
  027b be00     LD    X,__OVL_20_SCI_Compute_Baudrate_j
  027d 89       PUSH  X
  027e 9097     LD    Y,A
  0280 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  0282 88       PUSH  A
  0283 5f       CLR   X
  0284 909f     LD    A,Y
  0286 cd0000   CALL  _IMULU
  0289 b300     CP    X,__OVL_20_SCI_Compute_Baudrate_10_Presc_Fact
  028b 81       RET   
  028c a604     LD    A,#4
  028e 88       PUSH  A
  028f b603     LD    A,__OVL_20_SCI_Compute_Baudrate_temp:3
  0291 be02     LD    X,__OVL_20_SCI_Compute_Baudrate_temp:2
  0293 90be01   LD    Y,__OVL_20_SCI_Compute_Baudrate_temp:1
  0296 b701     LD    _LEX:1,A
  0298 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_temp
  029a b700     LD    _R_Z,A
  029c b601     LD    A,_LEX:1
  029e cd0000   CALL  _LLSR
  02a1 b701     LD    __OVL_20_SCI_Compute_Baudrate_10_Presc_Fact:1,A
  02a3 bf00     LD    __OVL_20_SCI_Compute_Baudrate_10_Presc_Fact,X
  02a5 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_i
  02a7 81       RET   
  02a8 b603     LD    A,__OVL_20_SCI_Compute_Baudrate_temp:3
  02aa b001     SUB   A,__OVL_20_SCI_Compute_Baudrate_count:1
  02ac b703     LD    __OVL_20_SCI_Compute_Baudrate_temp:3,A
  02ae be00     LD    X,__OVL_20_SCI_Compute_Baudrate_count
  02b0 b602     LD    A,__OVL_20_SCI_Compute_Baudrate_temp:2
  02b2 b200     SBC   A,__OVL_20_SCI_Compute_Baudrate_count
  02b4 b702     LD    __OVL_20_SCI_Compute_Baudrate_temp:2,A
  02b6 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_temp:1
  02b8 a200     SBC   A,#0
  02ba b701     LD    __OVL_20_SCI_Compute_Baudrate_temp:1,A
  02bc b600     LD    A,__OVL_20_SCI_Compute_Baudrate_temp
  02be a200     SBC   A,#0
  02c0 81       RET   
  02c1 b703     LD    __OVL_20_SCI_Compute_Baudrate_temp:3,A
  02c3 bf02     LD    __OVL_20_SCI_Compute_Baudrate_temp:2,X
  02c5 90bf01   LD    __OVL_20_SCI_Compute_Baudrate_temp:1,Y
  02c8 be00     LD    X,_R_Z
  02ca bf00     LD    __OVL_20_SCI_Compute_Baudrate_temp,X
  02cc 202b     JRT   *45 ;abs = 02f9
  02ce b601     LD    A,__OVL_20_SCI_Compute_Baudrate_count:1
  02d0 bb03     ADD   A,__OVL_20_SCI_Compute_Baudrate_temp:3
  02d2 b703     LD    __OVL_20_SCI_Compute_Baudrate_temp:3,A
  02d4 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_count
  02d6 b902     ADC   A,__OVL_20_SCI_Compute_Baudrate_temp:2
  02d8 b702     LD    __OVL_20_SCI_Compute_Baudrate_temp:2,A
  02da 4f       CLR   A
  02db b901     ADC   A,__OVL_20_SCI_Compute_Baudrate_temp:1
  02dd b701     LD    __OVL_20_SCI_Compute_Baudrate_temp:1,A
  02df 4f       CLR   A
  02e0 b900     ADC   A,__OVL_20_SCI_Compute_Baudrate_temp
  02e2 81       RET   
  02e3 3801     SLL   __OVL_20_SCI_Compute_Baudrate_j:1
  02e5 3900     RLC   __OVL_20_SCI_Compute_Baudrate_j
  02e7 2021     JRT   *35 ;abs = 030a
  02e9 a601     LD    A,#1
  02eb b701     LD    __OVL_20_SCI_Compute_Baudrate_j:1,A
  02ed 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_j
  02ef 81       RET   
  02f0 b700     LD    __OVL_20_SCI_Compute_Baudrate_11_Presc_Value,A
  02f2 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_TR1:1
  02f4 b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1,A
  02f6 b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TR1
  02f8 81       RET   
  02f9 3f01     CLR   __OVL_20_SCI_Compute_Baudrate_temp1:1
  02fb 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_temp1
  02fd a601     LD    A,#1
  02ff b701     LD    __OVL_20_SCI_Compute_Baudrate_count:1,A
  0301 3f00     CLR   __OVL_20_SCI_Compute_Baudrate_count
  0303 81       RET   
  0304 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_i
  0306 d60000   LD    A,(Pr_Value,X)
  0309 81       RET   
  030a b601     LD    A,__OVL_20_SCI_Compute_Baudrate_j:1
  030c be00     LD    X,__OVL_20_SCI_Compute_Baudrate_j
  030e a300     CP    X,#0
  0310 81       RET   
  0311 b601     LD    A,__OVL_20_SCI_Compute_Baudrate_temp1:1
  0313 be00     LD    X,__OVL_20_SCI_Compute_Baudrate_temp1
  0315 a300     CP    X,#0
  0317 81       RET   
  0318 b700     LD    __OVL_20_SCI_Compute_Baudrate_11_Presc_Value,A
  031a b601     LD    A,__OVL_20_SCI_Compute_Baudrate_TR2:1
  031c b701     LD    __OVL_20_SCI_Compute_Baudrate_8_Tx_Value:1,A
  031e b600     LD    A,__OVL_20_SCI_Compute_Baudrate_TR2
  0320 81       RET   
  317:  
  318:  #ifdef SCI_72F561
  319:  void SCI2_Compute_Baudrate ( unsigned int BaudRate_Tx,unsigned int BaudRate_Rx)
  320:  {
  321:      unsigned char  Presc_Value,TPR1, TPR2, RPR1, RPR2,i;
  322:      unsigned int  Tx_Value, Rx_Value,temp1;
  323:      unsigned int TR1, TR2, RR1, RR2,Presc_Fact,j,count;
  324:      unsigned long temp;        
  325:      TPR1 = 0;
  326:      TPR2 = 0;
  327:      RPR1 = 0;
  328:      RPR2 = 0; 
  329:      temp = 0; 
  330:      
  331:      temp = Fcpu/BaudRate_Tx;                       
  332:      for (temp1 = 0,count = 1;temp1 < 1;count++)    
  333:      {    
  334:          Presc_Fact = ((unsigned int)(temp/16)) ;
  335:          for (i = 0; i != 4; i++)
  336:          {
  337:              for (j = 1; j <= 128; j = j*2)
  338:              {
  339:                  if ( ((Pr_Value[i]*j) == Presc_Fact) && (TPR1 == 0) )
  340:                  {
  341:                      TPR1 = Pr_Value[i];     /*Prescalar value for Transmitter*/
  342:                      TR1  = j;                      /*Transmitter rate divisor*/
  343:                      temp1++;
  344:                  }
  345:                  else if ((Pr_Value[i]*j) == Presc_Fact)
  346:                  {
  347:                      TPR2 = Pr_Value[i]; 
  348:                                      /*Another Prescalar value for Transmitter*/
  349:                      TR2 = j;               /*Another Transmitter rate divisor*/
  350:                      temp1++;
  351:                  }
  352:              }
  353:          }   
  354:          if(count%2 == 0)      /*Changes the temp value if no prescalar factor
  355:                                                                       is found*/
  356:          {         
  357:              temp = temp + count;                           
  358:          }
  359:          else
  360:          {         
  361:              temp = temp - count;
  362:          }    
  363:      }               
  364:      temp = Fcpu/BaudRate_Rx; 
  365:      for (temp1 = 0,count = 1;temp1 < 1;count++)
  366:      {   
  367:          Presc_Fact = (unsigned int)(temp/16); 
  368:          for (i = 0; i != 4; i++)
  369:          {
  370:              for (j = 1; j <= 128; j = j*2)
  371:              {
  372:                  if (((Pr_Value[i]*j) == Presc_Fact) && (RPR1 == 0))
  373:                  {
  374:                      RPR1 = Pr_Value[i];        /*Prescalar value for Receiver*/
  375:                      RR1    = j;                        /*Receiver rate divisor*/
  376:                      temp1++;
  377:                  }
  378:                  else if ((Pr_Value[i]*j) == Presc_Fact)
  379:                  {
  380:                      RPR2 = Pr_Value[i];
  381:                                         /*Another Prescalar value for Receiver*/
  382:                      RR2    = j;               /*Another Receiver rate divisor*/
  383:                      temp1++;
  384:                  }
  385:              }
  386:          }
  387:          if(count%2 == 0)
  388:                       /*Changes the temp value if no prescalar factor is found*/                                                        
  389:          {     
  390:              temp = temp + count;
  391:          }
  392:          else
  393:          {     
  394:              temp = temp - count;
  395:          }
  396:      } 
  397:                  /*Searches common Prescalar factor for transmitter & receiver*/
  398:      if (TPR1 == RPR1)    
  399:      {
  400:          Presc_Value = TPR1;
  401:          Tx_Value    = TR1;
  402:          Rx_Value    = RR1;
  403:      }
  404:      else if ( TPR1 == RPR2)
  405:      {
  406:          Presc_Value = TPR1;
  407:          Tx_Value    = TR1;
  408:          Rx_Value    = RR2;
  409:      }
  410:      else if ( TPR2 == RPR1)
  411:      {
  412:          Presc_Value = TPR2;
  413:          Tx_Value    = TR2;
  414:          Rx_Value    = RR1;
  415:      }
  416:      else if ( TPR2 == RPR2)
  417:      {
  418:          Presc_Value = TPR2;
  419:          Tx_Value    = TR2;
  420:          Rx_Value    = RR2;
  421:      }   
  422:      else                    /*If no common prescalar division factor is found*/
  423:      {
  424:          for (temp1=0,count=1;temp1<1;count++)
  425:          {
  426:              for (j=1; j<=128; j= j*2)
  427:              {
  428:                  if ( (TPR1*j) == Presc_Fact)
  429:                  {
  430:                      Presc_Value = TPR1; 
  431:                      Tx_Value = TR1; 
  432:                      Rx_Value = j;
  433:                      temp1++; 
  434:                  }
  435:              }
  436:              if(count%2 == 0)
  437:              {     
  438:                  Presc_Fact = Presc_Fact+count;
  439:              }
  440:              else
  441:              {     
  442:                  Presc_Fact = Presc_Fact-count;
  443:              }
  444:          }
  445:      }    
  446:      if (Presc_Value == 1)
  447:      {
  448:          Presc_Value = 0;
  449:      }
  450:      else if (Presc_Value == 3)
  451:      {
  452:          Presc_Value = 1;
  453:      }
  454:      else if (Presc_Value == 4)
  455:      {
  456:          Presc_Value = 2;
  457:      }
  458:      else 
  459:      {
  460:          Presc_Value = 3;
  461:      }
  462:      for (i=0,j=1; j<=128; j=j*2)
  463:      {
  464:          if ( j == Tx_Value )
  465:          {
  466:              Tx_Value = i;
  467:          }
  468:          i++;
  469:      }
  470:      for (i=0,j=1; j<=128; j=j*2)
  471:      {
  472:      if ( j == Rx_Value )
  473:          {    
  474:              Rx_Value = i;
  475:          }
  476:          i++;
  477:      }  
  478:      Presc_Value <<= 6 ;
  479:      SCI2BRR &= SCI_PR ;  
  480:      SCI2BRR |= Presc_Value ;                            /*Loads the prescalar*/
  481:  
  482:      Tx_Value <<= 3 ;                     /*Loads the transmitter rate divisor*/
  483:      SCI2BRR &= SCI_TR ;
  484:      SCI2BRR |= (unsigned char)Tx_Value ;
  485:  
  486:      SCI2BRR &= SCI_RR ;                     /*Loads the receiver rate divisor*/
  487:      SCI2BRR |= (unsigned char)Rx_Value ;
  488:  }       
  489:  #endif
  490:  #endif /* REM_SCI_COMPUTE_BAUDRATE */
  491:  
  492:  /*-----------------------------------------------------------------------------
  493:  ROUTINE NAME    : SCI_Extend_BaudRate
  494:  INPUT           : SCI_PR_X+SCI_TR_Y+RR_Z,ETPR,ERPR 
  495:  OUTPUT          : None
  496:  DESCRIPTION     : Selects the possible baudrate with extended prescalar    
  497:  COMMENTS        : Values are to be precalculated by the user
  498:  -----------------------------------------------------------------------------*/
  499:  #if (defined SCI_72F521 || defined SCI_72F62 || defined SCI_LITE3 || \
  500:       defined SCI_72F264 || defined SCI_72F561 )
  501:  void SCI_Extend_Baudrate (SCI_Baudrate_Type Baudrate_Presc,
  502:                                           unsigned char ETPR,unsigned char ERPR)
  503:  {

Function: SCI_Extend_Baudrate
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 bf00     LD    __OVL_19_SCI_Extend_Baudrate_p1,X
  0002 b700     LD    __OVL_19_SCI_Extend_Baudrate_p0,A
  504:      SCIBRR = 0x00;
  0004 3f00     CLR   SCIBRR
  505:      SCIBRR |= (unsigned char)Baudrate_Presc; 
  0006 b600     LD    A,SCIBRR
  0008 ba00     OR    A,__OVL_19_SCI_Extend_Baudrate_p2
  000a b700     LD    SCIBRR,A
  506:                                              /*Loads the required value SCIBRR*/
  507:      SCIETPR = ETPR;                    /*loads the required value in SCIETPR */
  000c b600     LD    A,__OVL_19_SCI_Extend_Baudrate_p1
  000e b700     LD    SCIETPR,A
  508:      SCIERPR = ERPR;                    /*loads the required value in SCIERPR */
  0010 b600     LD    A,__OVL_19_SCI_Extend_Baudrate_p0
  0012 b700     LD    SCIERPR,A
  509:  }  
  0014 81       RET   
  510:  #endif
  511:  
  512:  #ifdef SCI_72F561
  513:  void SCI2_Extend_Baudrate (SCI_Baudrate_Type Baudrate_Presc,
  514:                                           unsigned char ETPR,unsigned char ERPR)
  515:  {
  516:      SCI2BRR = 0x00;
  517:      SCI2BRR |= (unsigned char)Baudrate_Presc;
  518:                                             /*Loads the required value SCIBRR*/
  519:      SCI2ETPR = ETPR;                   /*loads the required value in SCIETPR */
  520:      SCI2ERPR = ERPR;                   /*loads the required value in SCIERPR */
  521:  }  
  522:  #endif
  523:  
  524:  /*-----------------------------------------------------------------------------
  525:  ROUTINE NAME    : SCI_PutByte
  526:  INPUT           : Tx_DATA
  527:  OUTPUT          : None        
  528:  DESCRIPTION     : Transmits a single data byte
  529:  COMMENTS        : None
  530:  -----------------------------------------------------------------------------*/
  531:  void SCI_PutByte (unsigned char Tx_DATA)
  532:  {  

Function: SCI_PutByte
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  533:      unsigned char temp;
  534:      
  535:  #ifdef SCI_POLLING_TX
  536:      temp = SCISR;                          /*Loads the byte to be transmitted*/
  537:      SCIDR = Tx_DATA;
  538:  #endif
  539:  
  540:  #ifdef SCI_ITDRV_WITHOUTBUF_TX    
  541:      SCI_Tx_Buff = 1;                               /*Loads the default value */
  542:      SCI_Tx_String = 0;
  543:      temp = SCISR; 
  544:      SCIDR = Tx_DATA;                       /*Loads the byte to be transmitted*/
  545:      SCICR2 |= (unsigned char)SCI_TDRE;                   /* Enable Interrupt */
  546:  #endif
  547:  }       
  0000 81       RET   
  548:  
  549:  #ifdef SCI_72F561
  550:  void SCI2_PutByte (unsigned char Tx_DATA)
  551:  {  
  552:      unsigned char temp;
  553:      
  554:  #ifdef SCI2_POLLING_TX
  555:      temp = SCI2SR;                         /*Loads the byte to be transmitted*/
  556:      SCI2DR = Tx_DATA;
  557:  #endif
  558:  
  559:  #ifdef SCI2_ITDRV_WITHOUTBUF_TX    
  560:      SCI2_Tx_Buff = 1;                              /*Loads the default value */
  561:      SCI2_Tx_String = 0;
  562:      temp = SCI2SR; 
  563:      SCI2DR = Tx_DATA;                      /*Loads the byte to be transmitted*/
  564:      SCI2CR2 |= (unsigned char)SCI_TDRE;                    /*Enable Interrupt*/
  565:  #endif
  566:  }
  567:  #endif
  568:  /*-----------------------------------------------------------------------------
  569:  ROUTINE NAME    : SCI_IsTransmitCompleted
  570:  INPUT           : None    
  571:  OUTPUT          : TRUE or FALSE    
  572:  DESCRIPTION     : Checks if the transmission is completed or not
  573:  COMMENTS        : Must be called after Put_Byte or Put_Buffer or Put_String
  574:  -----------------------------------------------------------------------------*/
  575:  BOOL SCI_IsTransmitCompleted(void)
  576:  {

Function: SCI_IsTransmitCompleted
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  577:  #if defined SCI_ITDRV_WITHOUTBUF_TX 
  578:  unsigned char Temp;
  579:  #endif
  580:  #if defined SCI_POLLING_TX
  581:      if(SCISR & SCI_TC)                  /*Checks if transmission is completed*/
  582:      {
  583:          return (TRUE);
  584:      }
  585:      else 
  586:      {
  587:          return(FALSE);
  588:      }
  589:  #else
  590:  #if defined SCI_ITDRV_WITHOUTBUF_TX 
  591:      if (SCI_Tx_String == 1)
  592:      {
  593:      Temp = *PtrToSCIBuffTx ;
  594:          if( (SCISR & SCI_TDRE)&& (Temp == '\0')) 
  595:          {
  596:              return (TRUE);
  597:          }
  598:          else
  599:          {
  600:              return (FALSE);
  601:          }
  602:      }
  603:      else if (SCI_Tx_Buff == 0)
  604:      {
  605:          return (TRUE);
  606:      }
  607:      else
  608:      {
  609:          return (FALSE);
  610:      }
  611:  
  612:  #else
  613:      return(TRUE);                                    /*Dummy return statement*/
  0000 a601     LD    A,#1
  614:  #endif    
  615:  #endif
  616:  }
  0002 81       RET   
  617:  
  618:  #ifdef SCI_72F561
  619:  BOOL SCI2_IsTransmitCompleted(void)
  620:  {
  621:  #if defined SCI2_POLLING_TX
  622:      if(SCI2SR & SCI_TC)                 /*Checks if transmission is completed*/
  623:      {
  624:          return (TRUE);
  625:      }
  626:      else 
  627:      {
  628:          return(FALSE);
  629:      }
  630:  #else
  631:  #if defined SCI2_ITDRV_WITHOUTBUF_TX 
  632:      unsigned char Temp;                 
  633:      if (SCI2_Tx_String == 1)
  634:      {    
  635:          Temp = *PtrToSCI2BuffTx;
  636:          if( (SCI2SR & SCI_TDRE) && (Temp == '\0')) 
  637:          {
  638:              return (TRUE);
  639:          }
  640:          else
  641:          {
  642:             return (FALSE);
  643:          }
  644:      }
  645:      else if (SCI2_Tx_Buff == 0)
  646:      {
  647:          return (TRUE);
  648:      }
  649:      else
  650:      {
  651:          return (FALSE);
  652:      }
  653:  
  654:  #else
  655:      return(TRUE);                                 /*Dummy return statement*/
  656:  #endif    
  657:  #endif
  658:  }               
  659:  #endif
  660:  /*-----------------------------------------------------------------------------
  661:  ROUTINE NAME    : SCI_IT_Disable
  662:  INPUT           : SCI_IDLE_LINE,SCI_RECEIVE_OVERRUN,SCI_TRANSMIT_REGISTER_READY
  663:                   ,SCI_FRAME_TRANSMITTED,SCI_PARITY_ERROR
  664:  OUTPUT          : None
  665:  DESCRIPTION     : Disables the interrupt due to a particular flag
  666:  COMMENTS        : None
  667:  -----------------------------------------------------------------------------*/
  668:  void SCI_IT_Disable(SCI_IT_Type SCI_IT_Param)
  669:  { 

Function: SCI_IT_Disable
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  670:     SCICR2 &= (unsigned char)(~(unsigned char)((unsigned char)SCI_IT_Param & 
  0000 97       LD    X,A
  0001 a4fe     AND   A,#254
  0003 43       CPL   A
  0004 b400     AND   A,SCICR2
  0006 b700     LD    SCICR2,A
  671:                                          (~(unsigned char)(SCI_PARITY_ERROR))));
  672:                                              /*disables the selected interrupt*/
  673:     SCICR1 &= (unsigned char)(~(unsigned char)((unsigned char)SCI_IT_Param & 
  0008 9f       LD    A,X
  0009 a401     AND   A,#1
  000b 43       CPL   A
  000c b400     AND   A,SCICR1
  000e b700     LD    SCICR1,A
  674:                                               (unsigned char)SCI_PARITY_ERROR));    
  675:  } 
  0010 81       RET   
  676:  
  677:  #ifdef SCI_72F561
  678:  void SCI2_IT_Disable(SCI_IT_Type SCI_IT_Param)
  679:  { 
  680:     SCI2CR2 &= (unsigned char)(~(unsigned char)((unsigned char)SCI_IT_Param & 
  681:                                            (~(unsigned char)SCI_PARITY_ERROR)));  
  682:                                              /*disables the selected interrupt*/
  683:     SCI2CR1 &= (unsigned char)(~(unsigned char)((unsigned char)SCI_IT_Param & 
  684:                                               (unsigned char)SCI_PARITY_ERROR));     
  685:  }
  686:  #endif
  687:  
  688:  /*-----------------------------------------------------------------------------
  689:  ROUTINE NAME    : SCI_PutBuffer
  690:  INPUT           : *PtrtoBuffer,NbOfBytes
  691:  OUTPUT          : None
  692:  DESCRIPTION     : Transmits  data from the user buffer in polling mode and 
  693:                    starts transmission in interrupt driven with buffer mode
  694:  COMMENTS        : None
  695:  -----------------------------------------------------------------------------*/
  696:  void SCI_PutBuffer (const unsigned char *PtrtoBuffer, unsigned char NbOfBytes)
  697:  {  

Function: SCI_PutBuffer
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  698:      unsigned char temp;
  699:  #ifdef SCI_POLLING_TX
  700:      for (; NbOfBytes > 0 ; NbOfBytes--)
  701:      { 
  702:             temp = SCISR;
  703:          SCIDR = *PtrtoBuffer;              /*Loads the byte to be transmitted*/
  704:          while (!(SCI_IsTransmitCompleted()));  
  705:                                     /*Waits for the completion of transmission*/
  706:          PtrtoBuffer++;               /*Moves the pointer to the next location*/
  707:      } 
  708:  #endif
  709:  
  710:  #ifdef SCI_ITDRV_WITHOUTBUF_TX  
  711:      PtrToSCIBuffTx  = PtrtoBuffer; /*copies the user data to global variables*/    
  712:      SCI_Tx_Buff = NbOfBytes;
  713:      SCI_Tx_String = 0;
  714:      temp = SCISR;
  715:      SCIDR = *PtrToSCIBuffTx;        /*First byte is transmitted to generate the
  716:                                                                      interrupt*/
  717:      SCICR2 |= (unsigned char)SCI_TDRE;                     /*Enable Interrupt*/
  718:  #endif
  719:  }      
  0000 81       RET   
  720:  
  721:  #ifdef SCI_72F561
  722:  void SCI2_PutBuffer (const unsigned char *PtrtoBuffer, unsigned char NbOfBytes)
  723:  {  
  724:      unsigned char temp;
  725:  #ifdef SCI2_POLLING_TX
  726:      for (; NbOfBytes > 0 ; NbOfBytes--)
  727:      { 
  728:             temp = SCI2SR;
  729:          SCI2DR = *PtrtoBuffer;             /*Loads the byte to be transmitted*/
  730:          while (!(SCI2_IsTransmitCompleted()));  
  731:                                     /*Waits for the completion of transmission*/
  732:          PtrtoBuffer++;               /*Moves the pointer to the next location*/
  733:      } 
  734:  #endif
  735:  
  736:  #ifdef SCI2_ITDRV_WITHOUTBUF_TX  
  737:      PtrToSCI2BuffTx  = PtrtoBuffer;/*copies the user data to global variables*/    
  738:      SCI2_Tx_Buff = NbOfBytes;
  739:      SCI2_Tx_String = 0;
  740:      temp = SCI2SR;
  741:      SCI2DR = *PtrToSCI2BuffTx;      /*First byte is transmitted to generate the
  742:                                                                      interrupt*/
  743:      SCI2CR2 |= (unsigned char)SCI_TDRE;                    /*Enable Interrupt*/
  744:  #endif
  745:  }
  746:  #endif
  747:  /*-----------------------------------------------------------------------------
  748:  ROUTINE NAME    : SCI_PutString
  749:  INPUT           : *PtrtoString
  750:  OUTPUT          : None
  751:  DESCRIPTION     : Transmits the user string in polling mode and starts 
  752:                    transmission in interrupt driven mode
  753:  COMMENTS        : None
  754:  -----------------------------------------------------------------------------*/
  755:  void SCI_PutString(const unsigned char *PtrtoString)
  756:  {   

Function: SCI_PutString
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 b701     LD    __OVL_13_SCI_PutString_p0:1,A
  757:      unsigned char temp;
  758:  
  759:  #ifdef SCI_POLLING_TX 
  760:      unsigned char Val = *PtrtoString;
  761:      while (Val != '\0')                        /*Checks for the end of string*/
  762:      {
  763:          Val= *PtrtoString;                    
  764:          temp = SCISR;        
  765:          SCIDR = *PtrtoString;        /*Copies the character to be transmitted*/
  766:          while(!(SCI_IsTransmitCompleted()));   
  767:                                 /*waits for the completion of the transmission*/
  768:          PtrtoString++;               /*Moves the pointer to the next location*/
  769:      }    
  770:  #endif
  771:  
  772:  #ifdef SCI_ITDRV_WITHOUTBUF_TX 
  773:                  /*Copy the adress of the user string into the global variable*/
  774:      PtrToSCIBuffTx = PtrtoString;   
  775:     /*copy default value to recognize string transmission in interrupt routine*/
  776:      SCI_Tx_String = 1;               
  777:      SCI_Tx_Buff = 0;                                     
  778:      temp = SCISR;
  779:      SCIDR = *PtrToSCIBuffTx;/*transmits first character to generate interrupt*/
  780:      SCICR2 |= (unsigned char)SCI_TDRE;                     /*Enable Interrupt*/
  781:  #endif
  782:  } 
  0002 81       RET   
  783:  
  784:  #ifdef SCI_72F561
  785:  void SCI2_PutString(const unsigned char *PtrtoString)
  786:  {   
  787:      unsigned char temp;
  788:  
  789:  #ifdef SCI2_POLLING_TX 
  790:      unsigned char Val = *PtrtoString;
  791:      while (Val != '\0')                        /*Checks for the end of string*/
  792:      {
  793:          Val= *PtrtoString;                    
  794:          temp = SCI2SR;        
  795:          SCI2DR = *PtrtoString;       /*Copies the character to be transmitted*/
  796:          while(!(SCI2_IsTransmitCompleted()));   
  797:                                 /*waits for the completion of the transmission*/
  798:          PtrtoString++;               /*Moves the pointer to the next location*/
  799:      }    
  800:  #endif
  801:  
  802:  #ifdef SCI2_ITDRV_WITHOUTBUF_TX 
  803:                  /*Copy the adress of the user string into the global variable*/    
  804:      PtrToSCI2BuffTx = PtrtoString;  
  805:  /*copy default value to recognize string transmission in interrupt subroutine*/
  806:      SCI2_Tx_String = 1;              
  807:      SCI2_Tx_Buff = 0;                                     
  808:      temp = SCI2SR;
  809:                              /*transmits first character to generate interrupt*/
  810:      SCI2DR = *PtrToSCI2BuffTx;
  811:      SCI2CR2 |= (unsigned char)SCI_TDRE;                   /*Enable Interrupt */
  812:  #endif
  813:  }
  814:  #endif
  815:  /*-----------------------------------------------------------------------------
  816:  ROUTINE NAME    : SCI_9thBit_TxRx
  817:  INPUT           : TRUE or FALSE
  818:  OUTPUT          : TRUE or FALSE
  819:  DESCRIPTION     : Writes the 9th bit to be transmitted in the SCICR1 register 
  820:                    and returns the 9th bit received
  821:  COMMENTS        : 9 bit mode must be enabled.
  822:  -----------------------------------------------------------------------------*/
  823:  BOOL SCI_9thBit_TxRx(BOOL Bit9_Val)
  824:  {

Function: SCI_9thBit_TxRx
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  825:      if (Bit9_Val == TRUE)              /*If 9th bit is to be transmittes as 1*/
  0000 4a       DEC   A
  0001 2604     JRNE  *6 ;abs = 0007
  826:      {
  827:          SCICR1 |= SCI_TX_9TH;
  0003 1c00     BSET  SCICR1,#6
  828:      }
  0005 2002     JRT   *4 ;abs = 0009
  829:      else
  830:      {
  831:          SCICR1 &= (unsigned char)~(unsigned char)SCI_TX_9TH;
  0007 1d00     BRES  SCICR1,#6
  832:      }
  833:      if (SCICR1 & SCI_RX_9TH)                /*If the 9th bit is received as 1*/
  0009 0f0003   BTJF  SCICR1,#7,*6 ;abs = 000f
  834:      {
  835:          return (TRUE);
  000c a601     LD    A,#1
  000e 81       RET   
  836:      }
  837:      else
  838:      {
  839:          return (FALSE);
  000f 4f       CLR   A
  840:      }
  841:  }    
  0010 81       RET   
  842:  
  843:  #ifdef SCI_72F561
  844:  BOOL SCI2_9thBit_TxRx(BOOL Bit9_Val)
  845:  {
  846:      if (Bit9_Val == TRUE)              /*If 9th bit is to be transmittes as 1*/
  847:      {
  848:          SCI2CR1 |= SCI_TX_9TH;
  849:      }
  850:      else
  851:      {
  852:          SCI2CR1 &= (unsigned char)~(unsigned char)SCI_TX_9TH;
  853:      }
  854:      if (SCI2CR1 & SCI_RX_9TH)               /*If the 9th bit is received as 1*/
  855:      {
  856:          return (TRUE);
  857:      }
  858:      else
  859:      {
  860:          return (FALSE);
  861:      }
  862:  }
  863:  #endif                
  864:  /*-----------------------------------------------------------------------------
  865:  ROUTINE NAME    : SCI_GetByte
  866:  INPUT           : None
  867:  OUTPUT          : Received Data
  868:  DESCRIPTION     : Retunrs a data received to the user
  869:  COMMENTS        : None
  870:  -----------------------------------------------------------------------------*/
  871:  unsigned char SCI_GetByte(void)
  872:  {  

Function: SCI_GetByte
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  873:  #if defined SCI_POLLING_RX     
  874:      return(SCIDR);                     /*Returns the current value of the Data 
  0000 b600     LD    A,SCIDR
  875:                                                           register to the user*/
  876:  #else
  877:  
  878:  #if defined SCI_ITDRV_WITHOUTBUF_RX 
  879:      SCI_Error = 0x00;
  880:      return(SCI_MY_DATA);       
  881:  #else    
  882:      return (SCIDR);           
  883:  #endif
  884:  #endif
  885:  }
  0002 81       RET   
  886:  
  887:  #ifdef SCI_72F561
  888:  unsigned char SCI2_GetByte(void)
  889:  {  
  890:  #if defined SCI2_POLLING_RX     
  891:      return(SCI2DR);                     /*Returns the current value of the Data 
  892:                                                           register to the user*/
  893:  #else
  894:  
  895:  #if defined SCI2_ITDRV_WITHOUTBUF_RX 
  896:      SCI2_Error = 0x00;
  897:      return(SCI2_MY_DATA);       
  898:  #else    
  899:      return (SCI2DR);           
  900:  #endif
  901:  #endif
  902:  }
  903:  #endif
  904:  
  905:  /*-----------------------------------------------------------------------------
  906:  ROUTINE NAME    : SCI_GetBuffer
  907:  INPUT           : *PtrtoBuffer,NbOfBytes
  908:  OUTPUT          :  Error Status
  909:  DESCRIPTION     : Receives a continuous data,stores it into the user buffer and
  910:                    returns the error status to the user
  911:  COMMENTS        : Reception stops as soon as an error occurs
  912:  -----------------------------------------------------------------------------*/
  913:  #ifdef SCI_POLLING_RX
  914:  SCI_RxError_t SCI_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes)
  915:  {

Function: SCI_GetBuffer
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 b700     LD    __OVL_13_SCI_GetBuffer_p0,A
  916:      unsigned char Temp = 0x00 ;
  0002 3f00     CLR   __OVL_13_SCI_GetBuffer_Temp
  917:         
  918:      for (;((NbOfBytes > 0)&& (!(Temp))); --NbOfBytes)           
  0004 2014     JRT   *22 ;abs = 001a
  919:                                      /*Checks if all the bytes are transmitted*/
  920:      {   
  921:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);
  0006 ad1d     CALLR *31 ;abs = 0025
  922:          while (!(SCISR & SCI_RDRF)); 
  0008 0b00fd   BTJF  SCISR,#5,*0 ;abs = 0008
  923:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);
  000b ad18     CALLR *26 ;abs = 0025
  924:                                             /*waits for the next received byte*/
  925:          *PtrtoBuffer = SCIDR;  
  000d b600     LD    A,SCIDR
  000f 92c700   LD    [__OVL_13_SCI_GetBuffer_p1.w],A
  926:                                /*copies the received byte into the user buffer*/
  927:          PtrtoBuffer++;               /*Moves the pointer to the next location*/
  0012 3c01     INC   __OVL_13_SCI_GetBuffer_p1:1
  0014 2602     JRNE  *4 ;abs = 0018
  0016 3c00     INC   __OVL_13_SCI_GetBuffer_p1
  0018 3a00     DEC   __OVL_13_SCI_GetBuffer_p0
  001a b600     LD    A,__OVL_13_SCI_GetBuffer_p0
  001c 2704     JREQ  *6 ;abs = 0022
  001e b600     LD    A,__OVL_13_SCI_GetBuffer_Temp
  0020 27e4     JREQ  *-26 ;abs = 0006
  928:      } 
  929:      return((SCI_RxError_t)Temp);
  0022 b600     LD    A,__OVL_13_SCI_GetBuffer_Temp
  930:  }
  0024 81       RET   
  0025 b600     LD    A,SCISR
  0027 a40f     AND   A,#15
  0029 ba00     OR    A,__OVL_13_SCI_GetBuffer_Temp
  002b b700     LD    __OVL_13_SCI_GetBuffer_Temp,A
  002d 81       RET   
  931:  #endif 
  932:  
  933:  
  934:  #ifdef SCI_72F561
  935:  #ifdef SCI2_POLLING_RX
  936:  SCI_RxError_t SCI2_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes)
  937:  {
  938:      unsigned char Temp = 0x00 ;
  939:         
  940:      for (;((NbOfBytes > 0)&& (!(Temp))); --NbOfBytes)           
  941:                                      /*Checks if all the bytes are transmitted*/
  942:      {   
  943:          Temp |= (unsigned char)(SCI2SR & SCI_ErrValue);
  944:          while (!(SCI2SR & SCI_RDRF)); 
  945:          Temp |= (unsigned char)(SCI2SR & SCI_ErrValue);
  946:                                             /*waits for the next received byte*/
  947:          *PtrtoBuffer = SCI2DR;  
  948:                                /*copies the received byte into the user buffer*/
  949:          PtrtoBuffer++;               /*Moves the pointer to the next location*/
  950:      } 
  951:      return((SCI_RxError_t)Temp);
  952:  }
  953:  #endif
  954:  #endif
  955:  /*-----------------------------------------------------------------------------
  956:  ROUTINE NAME    : SCI_GetString
  957:  INPUT           : *PtrtoString
  958:  OUTPUT          : Error Status
  959:  DESCRIPTION     : Receives a string,Stores it in the user buffer and returns
  960:                    the error status to the user
  961:  COMMENTS        : Reception stops as soon as an error occurs
  962:  -----------------------------------------------------------------------------*/
  963:  #ifdef SCI_POLLING_RX
  964:  SCI_RxError_t SCI_GetString(unsigned char *PtrtoString)
  965:  {

Function: SCI_GetString
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

  0000 b701     LD    __OVL_13_SCI_GetString_p0:1,A
  0002 bf00     LD    __OVL_13_SCI_GetString_p0,X
  966:      unsigned char Temp = 0x00, Val = 0xff; 
  0004 3f00     CLR   __OVL_13_SCI_GetString_Temp
  967:   
  968:      for (;((Val != '\0')&&(Temp == 0));PtrtoString++)
  969:      {    
  970:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);   
  0006 ad1a     CALLR *28 ;abs = 0022
  971:          while (!(SCISR & SCI_RDRF));            /*waits for the received byte*/
  0008 0b00fd   BTJF  SCISR,#5,*0 ;abs = 0008
  972:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);         
  000b ad15     CALLR *23 ;abs = 0022
  973:                     /*Temp stores any error that occurred during the reception*/
  974:          *PtrtoString = SCIDR; 
  000d b600     LD    A,SCIDR
  000f 92c700   LD    [__OVL_13_SCI_GetString_p0.w],A
  0012 3c01     INC   __OVL_13_SCI_GetString_p0:1
  0014 2602     JRNE  *4 ;abs = 0018
  0016 3c00     INC   __OVL_13_SCI_GetString_p0
  0018 4d       TNZ   A
  0019 2704     JREQ  *6 ;abs = 001f
  001b b600     LD    A,__OVL_13_SCI_GetString_Temp
  001d 27e7     JREQ  *-23 ;abs = 0006
  975:                           /*Copies the received character into the user string*/
  976:          Val = *PtrtoString;
  977:      }  
  978:      return((SCI_RxError_t)Temp);       /*Returns the error status to the user*/
  001f b600     LD    A,__OVL_13_SCI_GetString_Temp
  979:  }
  0021 81       RET   
  0022 b600     LD    A,SCISR
  0024 a40f     AND   A,#15
  0026 ba00     OR    A,__OVL_13_SCI_GetString_Temp
  0028 b700     LD    __OVL_13_SCI_GetString_Temp,A
  002a 81       RET   
  980:  #endif
  981:  
  982:  #ifdef SCI_72F561
  983:  #ifdef SCI2_POLLING_RX
  984:  SCI_RxError_t SCI2_GetString(unsigned char *PtrtoString)
  985:  {
  986:      unsigned char Temp = 0x00, Val = 0xff; 
  987:   
  988:      for (;((Val != '\0')&&(Temp == 0));PtrtoString++)
  989:      {    
  990:          Temp |= (unsigned char)(SCI2SR & SCI_ErrValue);   
  991:          while (!(SCI2SR & SCI_RDRF));           /*waits for the received byte*/
  992:          Temp |= (unsigned char)(SCI2SR & SCI_ErrValue);          
  993:                     /*Temp stores any error that occurred during the reception*/
  994:          *PtrtoString = SCI2DR; 
  995:                           /*Copies the received character into the user string*/
  996:          Val = *PtrtoString;
  997:      }  
  998:      return((SCI_RxError_t)Temp);      /*Returns the error status to the user*/
  999:  }
 1000:  #endif           
 1001:  #endif
 1002:  
 1003:  /*-----------------------------------------------------------------------------
 1004:  ROUTINE NAME    : SCI_GetBuffer
 1005:  INPUT           : *PtrtoBuffer, NbOfBytes 
 1006:  OUTPUT          : None    
 1007:  DESCRIPTION     : Starts the reception in the interrupt subroutine
 1008:  COMMENTS        : Any data received before calling this function is ignored
 1009:  -----------------------------------------------------------------------------*/
 1010:  #ifdef SCI_ITDRV_WITHOUTBUF_RX
 1011:  void SCI_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes) 
 1012:  {
 1013:      PtrToSCIBuffRx = PtrtoBuffer;/*Copies user buffer to the global variable */
 1014:      SCI_Rx_Buff = NbOfBytes;
 1015:      SCI_Rx_Buff++;
 1016:      SCI_Error = 0x00;                                     
 1017:      SCICR2 |= (unsigned char)SCI_RDRF;                     /*Enable Interrupt*/    
 1018:  }                                                         
 1019:  
 1020:  /*-----------------------------------------------------------------------------
 1021:  ROUTINE NAME    : SCI_GetString
 1022:  INPUT           : *PtrtoString  
 1023:  OUTPUT          : None 
 1024:  DESCRIPTION     : Starts the reception of a string in the interrupt subroutine
 1025:  COMMENTS        : Any data received before calling this function is ignored
 1026:  -----------------------------------------------------------------------------*/
 1027:  void SCI_GetString(unsigned char *PtrtoString) 
 1028:  {
 1029:      PtrToSCIBuffRx = (PtrtoString); /*Copies the user buffer to global buffer*/
 1030:      SCI_Rx_String = 1;                        /*For String recognition in ISR*/ 
 1031:      SCI_Error = 0x00;
 1032:      SCICR2 |= (unsigned char)SCI_RDRF;                     /*Enable Interrupt*/    
 1033:  }
 1034:  #endif     
 1035:  
 1036:  #ifdef SCI_72F561
 1037:  #ifdef SCI2_ITDRV_WITHOUTBUF_RX
 1038:  void SCI2_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes) 
 1039:  {
 1040:      PtrToSCI2BuffRx = PtrtoBuffer;/*Copies user buffer to the global variable*/
 1041:      SCI2_Rx_Buff = NbOfBytes;
 1042:      SCI2_Rx_Buff++;
 1043:      SCI2_Error = 0x00;                                     
 1044:      SCI2CR2 |= (unsigned char)SCI_RDRF;                    /*Enable Interrupt*/    
 1045:  }                                                         
 1046:  
 1047:  void SCI2_GetString(unsigned char *PtrtoString) 
 1048:  {
 1049:      PtrToSCI2BuffRx = (PtrtoString);/*Copies the user buffer to global buffer*/
 1050:      SCI2_Rx_String = 1;                       /*For String recognition in ISR*/ 
 1051:      SCI2_Error = 0x00;
 1052:      SCI2CR2 |= (unsigned char)SCI_RDRF;                    /*Enable Interrupt*/    
 1053:  }
 1054:  #endif
 1055:  #endif
 1056:  /*-----------------------------------------------------------------------------
 1057:  ROUTINE NAME    : SCI_IsReceptionCompleted
 1058:  INPUT           : None
 1059:  OUTPUT          : Error Status
 1060:  DESCRIPTION     : Returns the error status occurred during the reception in the
 1061:                    interrupt subroutine if the reception is completed.
 1062:  COMMENTS        : Must be called after SCI_GetBuffer and SCI_GetString in 
 1063:                    Interrupt Driven mode to get the reception status.
 1064:                    Must be called before SCI_GetByte in interrupt Driven mode.
 1065:  -----------------------------------------------------------------------------*/
 1066:  SCI_RxError_t SCI_IsReceptionCompleted (void)  
 1067:  {   

Function: SCI_IsReceptionCompleted
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

 1068:  #if defined SCI_ITDRV_WITHOUTBUF_RX   
 1069:      unsigned char Temp_Error,Temp_BuffRx, Temp_PolStat, Temp_RxString ;
 1070:      SCI_Pol_Stat = 0;          
 1071:      Temp_Error = SCI_Error ;
 1072:      Temp_BuffRx = *(PtrToSCIBuffRx);
 1073:      Temp_PolStat =  SCI_Pol_Stat ;
 1074:      Temp_RxString = SCI_Rx_String;
 1075:  
 1076:      if ((SCI_Rx_String == 1) && ((Temp_BuffRx != '\0') &&(Temp_Error == 0)))
 1077:                                          /*String reception request undergoing*/
 1078:      {
 1079:          return(SCI_STRING_ONGOING);
 1080:      }  
 1081:      else if ((SCI_Rx_Buff > 1) && (Temp_Error == 0) ) 
 1082:                                          /*Buffer Reception request undergoing*/
 1083:      {   
 1084:          return(SCI_BUFFER_ONGOING) ;
 1085:      }
 1086:      else if ((SCI_Rx_Buff == 0) && ((Temp_RxString == 0) && (Temp_PolStat == 0)))    
 1087:                                                     /*Single Byte not received*/
 1088:      {
 1089:          return (SCI_RX_DATA_EMPTY);    
 1090:      }
 1091:      else                                             /*Reception is completed*/
 1092:      {       
 1093:          SCI_Pol_Stat = 0; 
 1094:          SCI_Rx_Buff = 0;
 1095:          SCI_Rx_String = 0;
 1096:          return ((SCI_RxError_t)SCI_Error);
 1097:      }           
 1098:  #else
 1099:  #if defined SCI_POLLING_RX
 1100:      if(SCISR & SCI_RDRF)
  0000 0b0005   BTJF  SCISR,#5,*8 ;abs = 0008
 1101:      {
 1102:          return ((SCI_RxError_t)(SCISR & SCI_ErrValue)); 
  0003 b600     LD    A,SCISR
  0005 a40f     AND   A,#15
  0007 81       RET   
 1103:      }
 1104:      else
 1105:      {
 1106:          return (SCI_RX_DATA_EMPTY);    /*Returns the error status to the user*/
  0008 a6fd     LD    A,#253
 1107:      }
 1108:  #else 
 1109:          return (SCI_RX_DATA_EMPTY);                  /*Dummy return statement*/
 1110:  #endif
 1111:  #endif        
 1112:  }     
  000a 81       RET   
 1113:  
 1114:  #ifdef SCI_72F561
 1115:  SCI_RxError_t SCI2_IsReceptionCompleted (void)  
 1116:  {   
 1117:  #if defined SCI2_ITDRV_WITHOUTBUF_RX          
 1118:      unsigned char Temp_BuffRx, Temp_PolStat, Temp_RxString, Temp_Error;
 1119:      SCI2_Pol_Stat = 0;          
 1120:  
 1121:      Temp_Error = SCI2_Error ;
 1122:      Temp_BuffRx = *(PtrToSCI2BuffRx);
 1123:      Temp_PolStat =  SCI2_Pol_Stat ;
 1124:      Temp_RxString = SCI2_Rx_String;
 1125:      if((SCI2_Rx_String == 1)&&((Temp_BuffRx != '\0')&&(Temp_Error == 0)))
 1126:                                          /*String reception request undergoing*/
 1127:      {
 1128:          return(SCI_STRING_ONGOING);
 1129:      }  
 1130:      else if ( (SCI2_Rx_Buff > 1) && (Temp_Error == 0)) 
 1131:                                          /*Buffer Reception request undergoing*/
 1132:      {   
 1133:          return(SCI_BUFFER_ONGOING) ;
 1134:      }
 1135:      else if ((SCI2_Rx_Buff == 0)&&((Temp_RxString == 0)&&(Temp_PolStat == 0)))    
 1136:                                                     /*Single Byte not received*/
 1137:      {
 1138:          return (SCI_RX_DATA_EMPTY);    
 1139:      }
 1140:      else                                             /*Reception is completed*/
 1141:      {       
 1142:          SCI2_Pol_Stat = 0; 
 1143:          SCI2_Rx_Buff = 0;
 1144:          SCI2_Rx_String = 0;
 1145:          return ((SCI_RxError_t)SCI2_Error);
 1146:      }           
 1147:  #else
 1148:  #if defined SCI2_POLLING_RX
 1149:      if(SCI2SR & SCI_RDRF)
 1150:      {
 1151:          return ((SCI_RxError_t)(SCI2SR & SCI_ErrValue)); 
 1152:      }
 1153:      else
 1154:      {
 1155:          return (SCI_RX_DATA_EMPTY);    /*Returns the error status to the user*/
 1156:      }
 1157:  #else 
 1158:          return (SCI_RX_DATA_EMPTY);                  /*Dummy return statement*/
 1159:  #endif
 1160:  #endif        
 1161:  }
 1162:  #endif
 1163:  /*-----------------------------------------------------------------------------
 1164:  ROUTINE NAME    : SCI_IT_Function
 1165:  INPUT           : None
 1166:  OUTPUT          : None
 1167:  DESCRIPTION     : Carries out communiction in Interrupt driven mode.
 1168:  COMMENTS        : This function must be called inside the SCI interrupt service
 1169:                    routine for Interrupt driven communication
 1170:  -----------------------------------------------------------------------------*/
 1171:  void  SCI_IT_Function (void)
 1172:  {                                                 

Function: SCI_IT_Function
Source  : C:\st7_lib2\peripherals\sci\sources\C\sci.c
Options : -Cc -Cni -F2 -Lasm=%n.lst -Ml -N -Or -TE1uE

 1173:  /******************************************************************************
 1174:  Reception in Interrupt Driven Without Buffer mode
 1175:  ******************************************************************************/
 1176:  unsigned char Temp_Buff;
 1177:  #ifdef SCI_ITDRV_WITHOUTBUF_RX   
 1178:      unsigned char Temp_Error,Temp_RxString,temp;
 1179:      if(SCISR & SCI_ORE)      /*If Interrupt is generated due to overrun error*/
 1180:      {
 1181:          SCI_Error = (unsigned char)(SCISR & SCI_ErrValue);
 1182:          temp = SCIDR;    
 1183:          SCI_Pol_Stat = 2;
 1184:      } 
 1185:      else if (SCISR & SCI_RDRF)
 1186:      {   
 1187:          Temp_Buff = *PtrToSCIBuffRx ;
 1188:          Temp_Error = SCI_Error ;
 1189:          Temp_RxString = SCI_Rx_String ;     
 1190:          if((SCI_Rx_String == 1)&&((Temp_Buff != '\0')&&(Temp_Error == 0)))     
 1191:                                                          /*If String Reception*/
 1192:          {       
 1193:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue);
 1194:              *PtrToSCIBuffRx = SCIDR;      
 1195:              if (*PtrToSCIBuffRx != '\0')
 1196:              {
 1197:                  PtrToSCIBuffRx++;
 1198:              }             
 1199:              else
 1200:              {
 1201:                  SCICR2 &= (unsigned char)(~(unsigned char)SCI_RDRF);    
 1202:                                                           /*Disable interrupt */
 1203:              }    
 1204:              SCI_Pol_Stat = 2;
 1205:          }
 1206:          else if ((SCI_Rx_Buff > 1) && (Temp_Error == 0))
 1207:          {              
 1208:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue) ;  
 1209:              *PtrToSCIBuffRx = SCIDR;
 1210:              SCI_Rx_Buff--;  
 1211:              SCI_Pol_Stat = 2;                       /*If a buffer is received*/
 1212:              PtrToSCIBuffRx++;  
 1213:              if(SCI_Rx_Buff == 1)
 1214:              { 
 1215:                  SCICR2 &= (unsigned char)(~(unsigned char)SCI_RDRF);   
 1216:                                                           /*Disable interrupt */
 1217:              }    
 1218:          }
 1219:          else if ((SCI_Rx_Buff == 0) && (Temp_RxString== 0))  
 1220:         /*If interrupt is generated before calling SCI_GetBuffer/SCI_GetString*/
 1221:          {  
 1222:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue) ;  
 1223:              SCI_MY_DATA = SCIDR;
 1224:              SCI_Pol_Stat = 1;
 1225:          }                    
 1226:          else
 1227:          {   
 1228:              SCI_Pol_Stat = 1;
 1229:              temp = SCIDR;
 1230:          }                
 1231:      }    
 1232:  #endif 
 1233:  
 1234:  /******************************************************************************
 1235:  Transmission in Interrupt Driven without Buffer mode
 1236:  ******************************************************************************/
 1237:  
 1238:  #ifdef SCI_ITDRV_WITHOUTBUF_TX 
 1239:      unsigned char Temp_CR2;
 1240:      Temp_CR2 = SCICR2 ;
 1241:                                  /*Checks if transmit complete flag is set*/
 1242:      if((SCISR & SCI_TC)&& (Temp_CR2 & SCI_TC))
 1243:      {   Temp_Buff = *PtrToSCIBuffTx  ;   
 1244:          if ((SCI_Tx_String == 1) && (Temp_Buff != '\0')) 
 1245:                                     /*Checks if complete string is transmitted*/
 1246:          {   
 1247:              PtrToSCIBuffTx++;
 1248:              SCIDR = *PtrToSCIBuffTx;
 1249:              if (*PtrToSCIBuffTx == '\0')
 1250:              {
 1251:                  SCICR2 &= (unsigned char)(~(unsigned char)SCI_TC);  
 1252:                                 /*Disable IT if complete string is transmitted*/
 1253:              } 
 1254:          } 
 1255:          else if (SCI_Tx_Buff > 1)   /*Checks if all the bytes are transmitted*/
 1256:          {
 1257:              SCI_Tx_Buff--; 
 1258:              PtrToSCIBuffTx++;            /*Moves the pointer to next location*/
 1259:              SCIDR = *PtrToSCIBuffTx;                /*Transmits a single byte*/
 1260:          }                          
 1261:          else if(SCI_Tx_Buff == 1)
 1262:          {
 1263:              SCI_Tx_Buff--;
 1264:              SCICR2 &= (unsigned char)(~(unsigned char)SCI_TC);     
 1265:                                 /*Disable IT if complete string is transmitted*/
 1266:          }
 1267:      }                                              
 1268:                                                   /*Checks if TDRE Flag is set*/
 1269:      else if ((SCISR & SCI_TDRE)&&(Temp_CR2 & SCI_TDRE))  
 1270:      {           
 1271:          Temp_Buff = *PtrToSCIBuffTx ;
 1272:                             /*Checks if complete string is transmitted*/
 1273:          if ((SCI_Tx_String == 1)&&(Temp_Buff != '\0')) 
 1274:          {   
 1275:             PtrToSCIBuffTx++;
 1276:             SCIDR = *PtrToSCIBuffTx;
 1277:             if (*PtrToSCIBuffTx == '\0')
 1278:             {    
 1279:                 Nop
 1280:                 SCICR2 &= (unsigned char)(~(unsigned char)SCI_TDRE);
 1281:                                 /*Disable IT if complete string is transmitted*/
 1282:                 Nop
 1283:             }    
 1284:  
 1285:          }
 1286:          else if (SCI_Tx_Buff > 1)   /*Checks if all the bytes are transmitted*/
 1287:          {
 1288:              SCI_Tx_Buff--; 
 1289:              PtrToSCIBuffTx++;            /*Moves the pointer to next location*/
 1290:              SCIDR = *PtrToSCIBuffTx;                /*Transmits a single byte*/
 1291:          }
 1292:          else if(SCI_Tx_Buff == 1)
 1293:          {
 1294:              SCI_Tx_Buff--;
 1295:              SCICR2 &= (unsigned char)(~(unsigned char)SCI_TDRE);
 1296:                                 /*Disable IT if complete string is transmitted*/
 1297:          } 
 1298:      }    
 1299:  #endif
 1300:  }
  0000 81       RET   
 1301:  
 1302:  
 1303:  #ifdef SCI_72F561
 1304:  void  SCI2_IT_Function (void)
 1305:  {                                                 
 1306:  /******************************************************************************
 1307:  Reception in Interrupt Driven Without Buffer mode
 1308:  ******************************************************************************/
 1309:  
 1310:  #ifdef SCI2_ITDRV_WITHOUTBUF_RX 
 1311:      unsigned char temp, Temp_Error, Temp_Buff, Temp_RxString, Temp_CR2;  
 1312:      if(SCI2SR & SCI_ORE)     /*If Interrupt is generated due to overrun error*/
 1313:      {
 1314:          SCI2_Error = (unsigned char)(SCI2SR & SCI_ErrValue);
 1315:          temp = SCI2DR;    
 1316:          SCI2_Pol_Stat = 2;
 1317:      } 
 1318:      else if (SCI2SR & SCI_RDRF)
 1319:      {   
 1320:          Temp_Buff = *PtrToSCI2BuffRx ;
 1321:          Temp_Error = SCI2_Error ;
 1322:          Temp_RxString = SCI2_Rx_String ;     
 1323:          if((SCI2_Rx_String == 1)&&((Temp_Buff != '\0')&&(Temp_Error == 0)))
 1324:                                                          /*If String Reception*/
 1325:          {       
 1326:              SCI2_Error = (unsigned char)(SCI2SR & SCI_ErrValue);
 1327:              *PtrToSCI2BuffRx = SCI2DR;      
 1328:              if (*PtrToSCI2BuffRx != '\0')
 1329:              {
 1330:                  PtrToSCI2BuffRx++;
 1331:              }             
 1332:              else
 1333:              {
 1334:                  SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_RDRF);  
 1335:                                                           /*Disable interrupt */
 1336:              }    
 1337:              SCI2_Pol_Stat = 2;
 1338:          }
 1339:          else if ((SCI2_Rx_Buff > 1) && (Temp_Error == 0))
 1340:          {              
 1341:              SCI2_Error = (unsigned char)(SCI2SR & SCI_ErrValue) ;  
 1342:              *PtrToSCI2BuffRx = SCI2DR;
 1343:              SCI2_Rx_Buff--;  
 1344:              SCI2_Pol_Stat = 2;                     /*If a buffer is received*/
 1345:              PtrToSCI2BuffRx++;  
 1346:              if(SCI2_Rx_Buff == 1)
 1347:              { 
 1348:                  SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_RDRF);  
 1349:                                                          /*Disable interrupt */
 1350:              }    
 1351:          }
 1352:          else if ((SCI2_Rx_Buff == 0) && (Temp_RxString == 0))  
 1353:         /*If interrupt is generated before calling SCI_GetBuffer/SCI_GetString*/
 1354:          {  
 1355:              SCI2_Error = (unsigned char)(SCI2SR & SCI_ErrValue) ;  
 1356:              SCI2_MY_DATA = SCI2DR;
 1357:              SCI2_Pol_Stat = 1;
 1358:          }                    
 1359:          else
 1360:          {   
 1361:              SCI2_Pol_Stat = 1;
 1362:              temp = SCI2DR;
 1363:          }                
 1364:      }    
 1365:  #endif 
 1366:  
 1367:  /******************************************************************************
 1368:  Transmission in Interrupt Driven without Buffer mode
 1369:  ******************************************************************************/
 1370:  
 1371:  #ifdef SCI2_ITDRV_WITHOUTBUF_TX 
 1372:      unsigned char temp, Temp_Error, Temp_Buff, Temp_RxString, Temp_CR2;  
 1373:                                      /*Checks if transmit complete flag is set*/
 1374:      Temp_CR2 = SCI2CR2 ;
 1375:      if((SCI2SR & SCI_TC)&& (Temp_CR2 & SCI_TC))
 1376:      {   Temp_Buff = *PtrToSCI2BuffTx  ;   
 1377:          if ((SCI2_Tx_String == 1) && (Temp_Buff != '\0')) 
 1378:                                     /*Checks if complete string is transmitted*/
 1379:          {   
 1380:              PtrToSCI2BuffTx++;
 1381:              SCI2DR = *PtrToSCI2BuffTx;
 1382:              if (*PtrToSCI2BuffTx == '\0')
 1383:              {
 1384:                  SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_TC);  
 1385:                                /*Disable IT if complete string is transmitted*/
 1386:              } 
 1387:          } 
 1388:          else if (SCI2_Tx_Buff > 1)  /*Checks if all the bytes are transmitted*/
 1389:          {
 1390:              SCI2_Tx_Buff--; 
 1391:              PtrToSCI2BuffTx++;           /*Moves the pointer to next location*/
 1392:              SCI2DR = *PtrToSCI2BuffTx;              /*Transmits a single byte*/
 1393:          }                          
 1394:          else if(SCI2_Tx_Buff == 1)
 1395:          {
 1396:              SCI2_Tx_Buff--;
 1397:              SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_TC);     
 1398:                                 /*Disable IT if complete string is transmitted*/
 1399:          }
 1400:      }                                            
 1401:                                                   /*Checks if TDRE Flag is set*/
 1402:      else if ((SCI2SR & SCI_TDRE)&&(Temp_CR2 & SCI_TDRE))  
 1403:      {           
 1404:          Temp_Buff = *PtrToSCI2BuffTx  ;/*Checks if complete string is transmitted*/
 1405:          if ((SCI2_Tx_String == 1)&&(Temp_Buff != '\0')) 
 1406:          {   
 1407:             PtrToSCI2BuffTx++;
 1408:             SCI2DR = *PtrToSCI2BuffTx;
 1409:             if (*PtrToSCI2BuffTx == '\0')
 1410:             {    
 1411:                 Nop
 1412:                 SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_TDRE);
 1413:                                 /*Disable IT if complete string is transmitted*/
 1414:                 Nop
 1415:             }    
 1416:  
 1417:          }
 1418:          else if (SCI2_Tx_Buff > 1)  /*Checks if all the bytes are transmitted*/
 1419:          {
 1420:              SCI2_Tx_Buff--; 
 1421:              PtrToSCI2BuffTx++;           /*Moves the pointer to next location*/
 1422:              SCI2DR = *PtrToSCI2BuffTx;              /*Transmits a single byte*/
 1423:          }
 1424:          else if(SCI2_Tx_Buff == 1)
 1425:          {
 1426:              SCI2_Tx_Buff--;
 1427:              SCI2CR2 &= (unsigned char)(~(unsigned char)SCI_TDRE);
 1428:                                 /*Disable IT if complete string is transmitted*/
 1429:          } 
 1430:      }    
 1431:  #endif
 1432:  }
 1433:  #endif
 1434:  /**** (c) 2002   STMicroelectronics *************************** END OF FILE **/ 
 1435:  
 1436:  
