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

📄 define.mac

📁 使用三星芯片的控制程序,可供三星8位MCU初学者参考!
💻 MAC
字号:
.include	"S3c9454.reg"

;;;;;;;;;define ram part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;general_ram:00h-0bfh
;work_register:0c0h-0cfh
   
serial_data       equ  00h      ;74ls164 data 
    
key_press_time1   equ  01h
key_press_time2   equ  02h

key_press_time    equ  03h     ;delay time counter 20ms
key_hold_flag     equ  04h      ;if press first #01 else #00
key_hold_down     equ  05h      ;if key already hold down       
key_value         equ  06h
key_value_store   equ  07H
key_add_flag      equ  08h
key_press_down    equ  0ah
key_realease_flag equ  0bh
key_release       equ  0ch


sound_backup      equ  0dh
lamp_backup       equ  0eh
fire_status       equ  10H
temp_status       equ  11h
lamp_status       equ  12h
sound_status      equ  13h
fire_value        equ  14h
temp_value        equ  15H

;**********************************************************
lamp_status_dress       equ   12H
sound_status_dress      equ   13H
fire_value_dress        equ   14H
temp_value_dress        equ   15H

I2C_SDA0   equ   0efH   ;SDA=P2.4=0  #1110 1111B
I2C_SDA1   equ   10H    ;SDA=P2.4=1  #0001 0000B
I2C_SCL0   equ   0dfH   ;SCL=P2.5=0  #1101 1111B
I2C_SCL1   equ   20H    ;SCL=P2.5=1  #0010 0000B
I2C_PORT   equ   P2
;**********************************************************
I2C_ack_flag    equ  16h
I2C_wrdata      equ  17h
I2C_rddata      equ  18h
I2C_data        equ  19h
I2C_dress       equ  1ah
;***********************************************
led_display_flag        equ  1bh        ;if led display #01H else #00H
led_15s_time1           equ  1ch           ;use to count led_sleep_time
led_15s_time2           equ  1dh


motor_value             equ  20h
motor_value_temp        equ  21h

ad_hdata                equ  22h
ad_ldata                equ  23h

beep_flag               equ  24h

common_counter          equ  25h
common_flag             equ  26h
motor_delay_time        equ  27h
beep_counter            equ  28h

ad_hdata_back           equ  29h
ad_hdata_1              equ  2ah
ad_hdata_2              equ  2bh
ad_hdata_3              equ  2ch
ad_hdata_4              equ  2dh
ad_hdata_5              equ  2eh

ad_hdata_a              equ  61h
ad_hdata_b              equ  62h
ad_hdata_temp           equ  63h
ad_comp_cnt             equ  64h

AD_convert_time         equ  65h
AD_convert_time1        equ  66h

remote_pulse_time       equ  30h        
remote_flag             equ  31h
remote_bit_num          equ  32h
remote_byte_num         equ  33h
remote_data             equ  34h
receive_end_flag        equ  35h
remote_byte_buf0        equ  40h
remote_byte_buf1        equ  41h
remote_byte_buf2        equ  42h
remote_byte_buf3        equ  43h

remote_repeat_start     equ  50h
remote_repeat_time      equ  51h
remote_again            equ  52h
remote_value            equ  53h
remote_repeat_flag      equ  54h

temp_sensor             equ  55h
not_sensor_counter1     equ  56h
not_sensor_counter2     equ  57h


temp                    equ  58h
holdkey_timeover        equ  59h

;key_first_delay         equ  5ah
;;;;;;;;;define mac part;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;************initial stack poiter********************
;this marco initials the system clock
;****************************************************
init_clock_sp:		.macro
        
        LD      CLKCON,#18H             ;CPU clock frequency = fxx

        
	LD	SP,#0c0h                ;00H-C0H
	
        .endm

;************initial ports macro*********************
;this macro initial P0-P2
;include use the port for I/O or special funtion
;if the port need pull up

;Port 0 Control Register:p0conl/p0conh

;0 0 = Schmitt trigger input
;0 1 = Schmitt trigger input; pull-up enable
;1 0 = Push-pull output
;1 1 = A/D converter input (ADC3); Schmitt trigger input off

init_port:		.macro

	;ld      p0conl,#10101001b       ;p0.0 uart input,other_output
        ld      p0conl,#10110100b
     
        ld      p0conh,#10101010b
        
        ld      P0,#00h
        
        ld      p1,#0ffh         
            
        ld      p0pnd,#00001000b        ;INT1 falling edge interrupt enable
                                
	ld      p1con,#00001010b        ;clock_circuit,reset_circuit
	
	ld      p2conl,#10101010b       ;led_scan_output: p2.0-3 output 
	ld      p2conh,#01001111b       ;led_scan_output: p2.0-3 output 
	
	ld      p2,#0ffH
	
        .endm

;***************initial timers**************
;this marco is used to initial all timers
;including base timer、timer0 、watch timer
;****************************************************

init_timer:		.macro

	;initial timer0
	;LD	T0CON,#10001000b        ;timers mode  8MHz
	;LD	T0CON,#01001010b	;Timer0 clock = fxx/8
	LD	T0CON,#10001010b        ;Timer0 interrupt enable
 
	;LD	T0DATA,#200
	LD	T0DATA,#38								
	.endm
	
;****************************************************	
enable_base_time:        .macro
	
	;initial base timer
	LD	BTCON,#0b2H		;enable watchdog timer ,Fxx/4096
					;Basic timer input clock=fxx/16
	.endm				
        					
;****************************************************	
disable_base_time:        .macro
	
	;initial base timer
	LD	BTCON,#0a2H		;disable watchdog timer ,Fxx/4096
					;Basic timer input clock=fxx/16
	.endm	

			       					

⌨️ 快捷键说明

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