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

📄 adc.l

📁 使用三星芯片的控制程序,可供三星8位MCU初学者参考!
💻 L
字号:
Sat Jan 14 09:29:55 2006


     SAM8 Assembler for Reduced Instruction  Ver. 2.15T(Win32)
         Copyright (c) 2003 Samsung Electronics Co.

    --------------------------------------------------------------------

                       Source File Name : ADC.src
                       Output File Name : ADC.o
                       List File Name   : ADC.l


    1                    
    2                    .include	"define.mac"
    3                    .include	"S3c9454.reg"
    4                    ; 86C4504.REG Copyright (c) 1996 SAMSUNG ELECTRONICS CO.
    5                    
    6                    	.list   on
    7                    
    8                    
    9                    ;*************************************************************
   10                    ;                   variable define    
   11         00 00      serial_data       equ  00h      ;74ls164 data 
   12         00 01      serial_clk_0      equ  01h               
   13         00 02      serial_clk_1      equ  02h      
   14                    
   15         00 03      key_press_time    equ  03h     ;delay time counter 20ms
   16         00 04      key_first_flag    equ  04h      ;if press first #01 else #00
   17         00 05      key_hold_down     equ  05h      ;if key already hold down       
   18         00 06      key_value         equ  06h
   19         00 07      key_value_store   equ  07H
   20         00 08      key_delay_time1   equ  08h      ;0.36S delay 
   21         00 09      key_delay_time2   equ  09H
   22         00 0A      key_press_down    equ  0ah
   23         00 0B      key_realease_flag equ  0bh
   24         00 0C      key_release       equ  0ch
   25                    
   26         00 10      fire_status       equ  10H
   27         00 11      temp_status       equ  11h
   28         00 12      lamp_status       equ  12h
   29         00 13      sound_status      equ  13h
   30         00 14      fire_value        equ  14h
   31         00 15      temp_value        equ  15H
   32                    ;**********************************************************
   33         00 12      lamp_status_dress       equ   12H
   34         00 13      sound_status_dress      equ   13H
   35         00 14      fire_value_dress        equ   14H
   36         00 15      temp_value_dress        equ   15H
   37                    
   38         00 EF      I2C_SDA0   equ   0efH   ;SDA=P2.4=0  #1110 1111B
   39         00 10      I2C_SDA1   equ   10H    ;SDA=P2.4=1  #0001 0000B
   40         00 DF      I2C_SCL0   equ   0dfH   ;SCL=P2.5=0  #1101 1111B
   41         00 20      I2C_SCL1   equ   20H    ;SCL=P2.5=1  #0010 0000B
   42         00 E2      I2C_PORT   equ   P2
   43                    ;**********************************************************
   44         00 16      I2C_ack_flag    equ  16h
   45         00 17      I2C_wrdata      equ  17h
   46         00 18      I2C_rddata      equ  18h
   47         00 19      I2C_data        equ  19h
   48         00 1A      I2C_dress       equ  1ah
   49                    ;***********************************************
   50         00 1B      led_display_flag        equ  1bh        ;if led display #01H else #00H
   51         00 1C      led_15s_time1           equ  1ch           ;use to count led_sleep_time
   52         00 1D      led_15s_time2           equ  1dh
   53         00 1E      led_15s_time3           equ  1eh
   54                    
   55         00 20      motor_value             equ  20h
   56         00 21      motor_value_temp        equ  21h
   57                    
   58         00 22      ad_hdata                equ  22h
   59         00 23      ad_ldata                equ  23h
   60                    
   61         00 24      beep_flag               equ  24h
   62         00 25      beep_time1              equ  25h
   63         00 26      beep_time2              equ  26h
   64                    
   65         00 30      remote_pulse_time       equ  30h        
   66         00 31      remote_flag             equ  31h
   67         00 32      remote_bit_num          equ  32h
   68         00 33      remote_byte_num         equ  33h
   69         00 34      remote_data             equ  34h
   70         00 35      receive_end_flag        equ  35h
   71         00 37      remote_byte_buf0        equ  37h
   72         00 38      remote_byte_buf1        equ  38h
   73         00 39      remote_byte_buf2        equ  39h
   74         00 40      remote_byte_buf3        equ  40h
   75         00 41      remote_byte_buf4        equ  41h
   76         00 42      remote_byte_buf5        equ  42h
   77         00 43      remote_byte_buf6        equ  43h
   78         00 44      remote_byte_buf7        equ  44h
   79         00 45      remote_byte_buf8        equ  45h
   80         00 46      remote_byte_buf9        equ  46h
   81         00 47      remote_byte_buf10       equ  47h
   82         00 48      remote_byte_buf11       equ  48h
   83         00 49      remote_byte_buf12       equ  49h
   84         00 4A      remote_byte_buf13       equ  4ah
   85         00 4B      remote_byte_buf14       equ  4bh
   86                    
   87                    
   88                    ;;;;;;;;;define ram part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   89                    ;general_ram:00h-0bfh
   90                    ;work_register:0c0h-0cfh
   91                    
   92                    
   93                    
   94                    ;;;;;;;;;define mac part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   95                    ;************initial stack poiter********************
   96                    ;this marco initials the system clock
   97                    ;****************************************************
   98                    init_clock_sp:		.macro
   99                            
  100                            LD      CLKCON,#18H             ;CPU clock frequency = fxx
  101                            
  102                    	LD	SP,#0c0h                ;00H-C0H
  103                    	
  104                            .endm
  105                    
  106                    ;************initial ports macro*********************
  107                    ;this macro initial P0-P2
  108                    ;include use the port for I/O or special funtion
  109                    ;if the port need pull up
  110                    
  111                    ;Port 0 Control Register:p0conl/p0conh
  112                    
  113                    ;0 0 = Schmitt trigger input
  114                    ;0 1 = Schmitt trigger input; pull-up enable
  115                    ;1 0 = Push-pull output
  116                    ;1 1 = A/D converter input (ADC3); Schmitt trigger input off
  117                    
  118                    init_port:		.macro
  119                    
  120                    	ld      p0conl,#10110101b       ;p0.0 key input p0.1 remo input p0.2 RT_AD input
  121                            ld      p0conh,#10101010b       ;p0.3-p0.7  output
  122                            ld      p1,#0ffh        
  123                            ld      p0pnd,#00000000b        ;INT1 falling edge interrupt enable
  124                                                    
  125                    	ld      p1con,#00001010b        ;p1.0 not use,p1.1 output,reset_circuit
  126                    	
  127                    	ld      p2conl,#10101010b       ;p2.3-p2.0 output 164_data 164_slk 
  128                    	ld      p2conh,#01001010b       ;p2.6-p2.4 output I2c_SDA I2C_SCL 
  129                    	
  130                    	ld      p2,#0ffH
  131                    	
  132                            .endm
  133                    
  134                    ;***************initial timers**************
  135                    ;this marco is used to initial all timers
  136                    ;including base timer、timer0 、watch timer
  137                    ;****************************************************
  138                    
  139                    init_timer:		.macro
  140                    
  141                    	;initial timer0
  142                    	LD	T0CON,#10001000b        ;timers mode  3.2MHz
  143                    					;Timer0 clock = fxx/8
  144                    					;Timer0 interrupt enable
  145                    	LD	T0DATA,#50              ;50*0.3125*8=125us                  
  146                    									
  147                    	.endm
  148                    	
  149                    ;****************************************************	
  150                    enable_base_time:        .macro
  151                    	
  152                    	;initial base timer
  153                    	LD	BTCON,#0b2H		;enable watchdog timer ,Fxx/4096
  154                    					;Basic timer input clock=fxx/16
  155                    	.endm				
  156                            					
  157                    ;****************************************************	
  158                    disable_base_time:        .macro
  159                    	
  160                    	;initial base timer
  161                    	LD	BTCON,#0a2H		;disable watchdog timer ,Fxx/4096
  162                    					;Basic timer input clock=fxx/16
  163                    	.endm	
  164                    
  165                    
  166                    
  167                    
  168                    		       					
  169                    
  170                    
  171                    .public  AD_judge
  172                    
  173                    
  174                    ;***************************************************************
  175  0EE0              AD_judge:
  176  0EE0   76 11 01           tm  temp_status,#01H
  177  0EE3   EB 1B              jr  ne,AD_judge_end
  178  0EE5   F6 0F 09           call  AD_convert
  179  0EE8   2C 0B              ld  r2,#0bh
  180  0EEA   38 15              ld  r3,temp_value
  181  0EEC   E7 02 30           ldc r0,#30h[rr2]
  182  0EEF   A4 C0 22           cp  ad_hdata,r0
  183  0EF2   BB 0D              jr  ugt,temp_ad_off
  184                            
  185  0EF4   2C 0B              ld  r2,#0bh
  186  0EF6   38 15              ld  r3,temp_value
  187  0EF8   E7 02 40           ldc r0,#40h[rr2]
  188  0EFB   A4 C0 22           cp  ad_hdata,r0
  189  0EFE   7B 05              jr  ult,temp_ad_on
  190  0F00              AD_judge_end:
  191  0F00   AF                 ret
  192                            
  193                            
  194  0F01              temp_ad_off:
  195  0F01   46 E0 80           or  p0,#80h             ;set p0.7  heater off
  196  0F04   AF                 ret  
  197                            
  198  0F05              temp_ad_on:
  199  0F05   56 E0 7F           and p0,#7fh             ;clea p0.7  heater on
  200  0F08   AF                 ret       
  201                    ;***************************************************************
  202                    
  203                    ;****************************************************************
  204  0F09              AD_convert:
  205  0F09   E6 F7 25           ld  adcon,#00100101B   ;select P0.2  f=fosc/4  start convert
  206  0F0C   F6 0F 23           call  delay2ms
  207  0F0F   76 F7 08           tm  adcon,#00001000B
  208  0F12   6B 08              jr  z,ad_error
  209  0F14   E4 F8 22           ld  ad_hdata,addatah
  210  0F17   E4 F9 23           ld  ad_ldata,addatal
  211  0F1A   8B 06              jr  ad_done
  212  0F1C              ad_error:
  213  0F1C   E6 22 00           ld  ad_hdata,#00H
  214  0F1F   E6 23 00           ld  ad_ldata,#00H
  215  0F22              ad_done:
  216  0F22   AF                 ret
  217                    ;*****************************************************************
  218  0F23              delay2ms:
  219  0F23   0C FF              ld  r0,#0ffH
  220  0F25              dalay_loop:
  221  0F25   00 C0              dec r0
  222  0F27   FF                 nop
  223  0F28   6B 02              jr z,delay2ms_end
  224  0F2A   8B F9              jr dalay_loop
  225  0F2C              delay2ms_end:       
  226  0F2C   AF                 ret
  227                    ;******************************************************************    
  228  0F2D                  .end


Total 61 Lines Assembled - 0 Errors, 0 Warnings
Total code size 0x4D


⌨️ 快捷键说明

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