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

📄 utility.lst

📁 基于摩托罗拉S12标准源程序 包括:SCIO,Timer
💻 LST
📖 第 1 页 / 共 5 页
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.21, Sep 27 2000

    1:  /******************************************************************************
    2:  * 		                                            COPYRIGHT (c) MOTOROLA 2002   
    3:  * FILE NAME: utility.c   REVISION R1D                                                  
    4:  *                                                                           
    5:  * PURPOSE: This module handles all tasks related to the rs232 port
    6:  *                                                                       
    7:  *******************************************************************************
    8:  *******************************************************************************  
    9:  **  THIS CODE IS ONLY INTENDED AS AN EXAMPLE FOR THE METROWERKS COMPILER AND **  
   10:  **      THE HCS	12 EVB AND HAS ONLY BEEN GIVEN A MIMIMUM LEVEL OF TEST.      **  
   11:  **  IT IS PROVIDED 'AS SEEN' WITH NO GUARANTEES AND NO PROMISE OF SUPPORT.   **  
   12:  *******************************************************************************  
   13:  *******************************************************************************
   14:  *                                                                           
   15:  * DOCUMENTATION SOURCE: Motorola TSPG 8/16 MCU bit Division (HKG)                                       
   16:  *                                                                           
   17:  * TARGET DEVICE: 		Hardware EVB912DP256 or equivalent                                                                                                                                                      
   18:  *                                                                           
   19:  * INCLUDE FILES:  		<hidef.h>
   20:  *						<math.h>
   21:  *						"ut_extern.h"
   22:  *						"DP256Port.h"
   23:  *						"GlobalVar.h"						
   24:  *                                                    
   25:  * FUNCTIONS :  			init_SCI0
   26:  *						tx_char0
   27:  *						printf0
   28:  *						delay1
   29:  *						int_div
   30:  *                       hex_clk_dec
   31:  *						rx_char0
   32:  *						menurx_char0
   33:  *						check_user_abort
   34:  *						send_asc
   35:  *						hex_asc
   36:  *						hex_asc_sp
   37:  *						int_div
   38:  *						input_int
   39:  *						input_word
   40:  *						input_byte
   41:  *						input_string
   42:  *						input_dec
   43:  *						data_display
   44:  *						init_RAM_start_address
   45:  *						modify_ram
   46:  *                                                                       
   47:  * COMPILER: Metrowerks                     VERSION: ADS v1.2           
   48:  *                                                                           
   49:  * DESCRIPTION: Program to control the SCI0 module to send and receive ASCII 
   50:  * 			   to and from PC serial port RS232 
   51:  *              
   52:  * INPUTS
   53:  * ------      
   54:  * All commands are inovked by PC Hyperterminal via SCI0
   55:  *
   56:  * NOTES
   57:  * -----
   58:  * All modules remain at their reset addresses.                                                      
   59:  *                                                                         
   60:  *                                                                         
   61:  * UPDATE HISTORY                                                         
   62:  * REV      AUTHOR       DATE       DESCRIPTION OF CHANGE                  
   63:  * ---      ------      ---------   ---------------------                 
   64:  * R1A      r29566	   02/04/27    Initial version
   65:  * R1B  	   r29566	   02/12/18    Demo version
   66:  *               
   67:  ******************************************************************************/                                                                        
   68:  /*===========================================================================*/
   69:  /* Motorola reserves the right to make changes without further notice to any */
   70:  /* product herein to improve reliability, function, or design. Motorola does */
   71:  /* not assume any  liability arising  out  of the  application or use of any */
   72:  /* product,  circuit, or software described herein;  neither  does it convey */
   73:  /* any license under its patent rights  nor the  rights of others.  Motorola */
   74:  /* products are not designed, intended,  or authorized for use as components */
   75:  /* in  systems  intended  for  surgical  implant  into  the  body, or  other */
   76:  /* applications intended to support life, or  for any  other application  in */
   77:  /* which the failure of the Motorola product  could create a situation where */
   78:  /* personal injury or death may occur. Should Buyer purchase or use Motorola */
   79:  /* products for any such intended  or unauthorized  application, Buyer shall */
   80:  /* indemnify and  hold  Motorola  and its officers, employees, subsidiaries, */
   81:  /* affiliates,  and distributors harmless against all claims costs, damages, */
   82:  /* and expenses, and reasonable  attorney  fees arising  out of, directly or */
   83:  /* indirectly,  any claim of personal injury  or death  associated with such */
   84:  /* unintended or unauthorized use, even if such claim alleges that  Motorola */
   85:  /* was negligent regarding the  design  or manufacture of the part. Motorola */
   86:  /* and the Motorola logo* are registered trademarks of Motorola Ltd.         */
   87:  /*****************************************************************************/
   88:  
   89:  #include <hidef.h>
   90:  #include <math.h>
   91:  #include "const.h"
   92:  #include "ut_extern.h"
   93:  #include "DP256Port.h"
   94:  #include "GlobalVar.h"
   95:  
   96:  /*******************************************************************
   97:  * Init SCI port 0 as baud 9600 subroutine
   98:  * Description : Initial SCI as 9600 and enable tx and rx
   99:  *			  :
  100:  * Example     : N/A  
  101:  * Input 	  : N/A
  102:  * Output	  : N/A
  103:  * Modify      : N/A
  104:  * Return      : N/A
  105:  ********************************************************************/ 
  106:  void init_SCI0 () 
  107:  {  

Function: init_SCI0
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  108:      SC0BDW=Eclock/16/9600;		//9600 buad rate	
  0000 c634         LDAB  #52
  0002 87           CLRA  
  0003 5cc8         STD   200
  109:    	SC0CR2=0xc;					//enable tx,rx
  0005 c60c         LDAB  #12
  0007 5bcb         STAB  203
  110:  }
  0009 3d           RTS   
  111:  
  112:  /*******************************************************************
  113:  * Transmit char (ASCII) subroutine 
  114:  * Description : Transmit ascii via RS232
  115:  *			  :
  116:  * Example     : N/A  
  117:  * Input 	  : data
  118:  * Output	  : single ascii to screen 
  119:  * Modify      : N/A
  120:  * Return      : N/A
  121:  ********************************************************************/ 
  122:  void tx_char0(char data)
  123:  {

Function: tx_char0
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  0000 37           PSHB  
  124:  	while ((SC0SR1&0x40)!=0x40);
  0001 4fcc40fc     BRCLR 204,#64,*+0 ;abs = 0001
  125:  	SC0DRL = data;
  0005 e680         LDAB  0,SP
  0007 5bcf         STAB  207
  126:  }
  0009 32           PULA  
  000a 3d           RTS   
  127:  
  128:  /*******************************************************************
  129:  * printf0 subroutine
  130:  * Description : Transmit string via RS232
  131:  *			  :
  132:  * Example     : N/A  
  133:  * Input 	  : *str
  134:  * Output	  : ascii to screen without lf and cr at the end
  135:  * Modify      : N/A
  136:  * Return      : N/A
  137:  ********************************************************************/ 
  138:  void printf0(char *str)
  139:  {	

Function: printf0
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  0000 3b           PSHD  
  140:  	while((*str != '\r'))
  0001 2010         BRA   *+18 ;abs = 0013
  141:  	{
  142:  		tx_char0(*str);
  0003 0700         BSR   tx_char0
  143:  		if(*str++=='\n')
  0005 ee80         LDX   0,SP
  0007 e630         LDAB  1,X+
  0009 6e80         STX   0,SP
  000b c10a         CMPB  #10
  000d 2604         BNE   *+6 ;abs = 0013
  144:  		  tx_char0('\r');		
  000f c60d         LDAB  #13
  0011 0700         BSR   tx_char0
  0013 ee80         LDX   0,SP
  0015 e600         LDAB  0,X
  0017 c10d         CMPB  #13
  0019 26e8         BNE   *-22 ;abs = 0003
  145:  	}
  146:  }
  001b 3a           PULD  
  001c 3d           RTS   
  147:  
  148:  /**********************************************
  149:  * eat time subroutine
  150:  ***********************************************/
  151:  void delay1()
  152:  {	

Function: delay1
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  0000 3b           PSHD  
  153:  	unsigned int data;
  154:  
  155:  	data=0xffff;
  0001 ccffff       LDD   #65535
  0004 6c80         STD   0,SP
  156:  	while((data--)!=0);
  0006 ee80         LDX   0,SP
  0008 191f         LEAY  -1,X
  000a 6d80         STY   0,SP
  000c 0475f7       TBNE  X,*-6 ;abs = 0006
  157:  }
  000f 3a           PULD  
  0010 3d           RTS   
  158:  
  159:  /*******************************************************************
  160:  * int_div subroutine
  161:  * Description : Integer Divide Subroutine
  162:  *			  :
  163:  * Example     : N/A  
  164:  * Input 	  : Intger to be divide, Divider 
  165:  * Output	  : .quot, .mem
  166:  * Modify      : N/A
  167:  * Return      : N/A
  168:  ********************************************************************/ 
  169:  div_t int_div( int num, int denum)
  170:  { 	

Function: int_div
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  0000 3b           PSHD  
  171:  	div_t static result;
  172:    	
  173:    	result.quot = 0;  
  0001 c7           CLRB  
  0002 87           CLRA  
  0003 7c0000       STD   result
  174:      while(num >= denum)
  0006 200b         BRA   *+13 ;abs = 0013
  175:      {
  176:        num -= denum;
  0008 a380         SUBD  0,SP
  000a 6c84         STD   4,SP
  177:        result.quot++;
  000c fe0000       LDX   result
  000f 08           INX   
  0010 7e0000       STX   result
  0013 ec84         LDD   4,SP
  0015 ac80         CPD   0,SP
  0017 2cef         BGE   *-15 ;abs = 0008
  178:      }
  179:      result.rem = num;
  0019 7c0000       STD   result:2
  180:      return(result);
  001c fe0000       LDX   result
  181:  }
  001f 31           PULY  
  0020 3d           RTS   
  182:  
  183:  /*******************************************************************
  184:  * Convert HEX to DEC and send out ASCII subroutine
  185:  * Description : Convert hex to dec and send out via RS232  
  186:  *             : 
  187:  *			  :
  188:  * Example     : 0x32 <=> 50 
  189:  * Input 	  : 0x32 (cdata)
  190:  * Output	  : 5 0 (ascii)
  191:  * Modify      : N/A
  192:  * Return      : void
  193:  ********************************************************************/ 
  194:  void hex_clk_dec(unsigned char data)
  195:  {

Function: hex_clk_dec
Source  : D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources\utility.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\cmd;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\prm;D:\Code S12\Utility\S12 Ex5 EEPROM ICD\sources;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior MOT_V1.2\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12 Ex5 EEPROM ICD\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12 Ex5 EEPROM ICD\S12_Ex5_EEPROM_ICD_Data\Flash_Application\ObjectCode\utility.c.o" -Ol0

  196:  	div_t static digit;
  197:  
  198:  	digit=int_div((int)data,10);
  0000 87           CLRA  
  0001 3b           PSHD  
  0002 c60a         LDAB  #10
  0004 0700         BSR   int_div
  0006 31           PULY  
  0007 7c0000       STD   digit:2
  000a 7e0000       STX   digit
  199:  	tx_char0(digit.quot+'0'); 
  000d f60000       LDAB  digit:1
  0010 cb30         ADDB  #48
  0012 0700         BSR   tx_char0
  200:  	tx_char0(digit.rem+'0'); 	
  0014 f60000       LDAB  digit:3
  0017 cb30         ADDB  #48
  0019 060000       JMP   tx_char0
  201:  }
  202:  
  203:  
  204:  /*******************************************************************
  205:  * Wait for receiving char subroutine
  206:  * Description : Waiting for rx char
  207:  *			  :
  208:  * Example     : N/A  
  209:  * Input 	  : N/A
  210:  * Output	  : N/A
  211:  * Modify      : N/A

⌨️ 快捷键说明

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