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

📄 hd_support.s

📁 一个直流电机的闭环控制源代码程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module HD_Support.c
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.area vector(rom, abs)
	.org 18
	rjmp _Timer0_OVF_ISR
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.area vector(rom, abs)
	.org 22
	rjmp _USART0_RX_ISR
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.area vector(rom, abs)
	.org 26
	rjmp _USART0_TX_ISR
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.area vector(rom, abs)
	.org 4
	rjmp _INT1_ISR
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.area vector(rom, abs)
	.org 2
	rjmp _INT0_ISR
	.area text(rom, con, rel)
	.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\HD_Support.c
	.dbfunc e Device_INIT _Device_INIT fV
	.even
_Device_INIT::
	.dbline -1
	.dbline 106
; /***********************************************************
; *   函数库说明:底层硬件初始化函数库                       *
; *   版本:                                                 *
; *   作者:                                                 *
; *   创建日期:                                             *
; * -------------------------------------------------------- *
; *  [硬件说明]                                              *
; *   处理器:                                               *
; *   系统时钟:                                             *
; * -------------------------------------------------------- *
; *  [支 持 库]                                              *
; *   支持库名称:PF_Config.h                                *
; *   需要版本:  -----                                      *
; *   声明库说明:硬件平台配置声明库                         *
; *                                                          *
; *   支持库名称:HD_Support.h                               *
; *   需要版本:  -----                                      *
; *   声明库说明:底层硬件初始化声明库                       *
; * -------------------------------------------------------- *
; *  [版本更新]                                              *
; *   修改:                                                 *
; *   修改日期:                                             *
; *   版本:                                                 *
; * -------------------------------------------------------- *
; *  [版本历史]                                              *
; * -------------------------------------------------------- *
; *  [使用说明]                                              *
; ***********************************************************/
; 
; /********************
; * 头 文 件 配 置 区 *
; ********************/
; # include "PF_Config.h"
; # include "HD_Support.h"
; # include "LIB_Config.h"
; 
; /********************
; *   系 统 宏 定 义  *
; ********************/
; # pragma interrupt_handler Timer0_OVF_ISR:iv_TIMER0_OVF
; # pragma interrupt_handler USART0_RX_ISR:iv_USART0_RXC
; # pragma interrupt_handler USART0_TX_ISR:iv_USART0_TXC
; # pragma interrupt_handler INT1_ISR:iv_INT1
; # pragma interrupt_handler INT0_ISR:iv_INT0
; 
; /*------------------*
; *   常 数 宏 定 义  *
; *------------------*/
; 
; /*------------------*
; *   动 作 宏 定 义  *
; *------------------*/
; #ifndef INSERT_TIMER0_OVF_ISR_CODE
;     # define INSERT_TIMER0_OVF_ISR_CODE
; #endif
; 
; #ifndef INSERT_USART0_RX_ISR_CODE
;     # define INSERT_USART0_RX_ISR_CODE
; #endif
; 
; #ifndef INSERT_USART0_TX_ISR_CODE
;     # define INSERT_USART0_TX_ISR_CODE
; #endif
; 
; #ifndef INSERT_INT0_ISR_CODE
;     # define INSERT_INT0_ISR_CODE
; #endif
; 
; #ifndef INSERT_INT1_ISR_CODE
;     # define INSERT_INT1_ISR_CODE
; #endif
; /********************
; *  模块结构体定义区 *
; ********************/
; 
; /********************
; *   函 数 声 明 区  *
; ********************/
; void Device_INIT(void);
; 
; /********************
; *   模块函数声明区  *
; ********************/
; static void Port_INIT(void);
; static void Timer0_INIT(void);
; static void USART0_INIT(void);
; static void Timer1_INIT(void);
; static void Extend_INT_INIT(void);
; 
; /********************
; *   模块变量声明区  *
; ********************/
; 
; /********************
; *   全局变量声明区  *
; ********************/
; 
; 
; /***********************************************************
; *   函数说明:系统硬件初始化函数                           *
; *   输入:    无                                           *
; *   输出:    无                                           *
; *   调用函数:Port_INIT()   Timer0_INIT()                  *
; ***********************************************************/
; void Device_INIT(void)
; {
	.dbline 107
;     Port_INIT();
	rcall _Port_INIT
	.dbline 108
;     Timer0_INIT();
	rcall _Timer0_INIT
	.dbline 109
;     USART0_INIT();
	rcall _USART0_INIT
	.dbline 110
;     Timer1_INIT();
	rcall _Timer1_INIT
	.dbline 111
;     Extend_INT_INIT();
	rcall _Extend_INT_INIT
	.dbline 113
;     
;     TIMSK = BIT(TOIE0);                                     //启动定时期0溢出中断资源
	ldi R24,1
	out 0x39,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc s Extend_INT_INIT _Extend_INT_INIT fV
	.even
_Extend_INT_INIT:
	.dbline -1
	.dbline 123
; }
; 
; /***********************************************************
; *   函数说明:外中断初始化函数                             *
; *   输入:    无                                           *
; *   输出:    无                                           *
; *   调用函数:无                                           *
; ***********************************************************/
; static void Extend_INT_INIT(void)
; {
	.dbline 124
;    SET_INT0_RAISING_EDGE
	in R24,0x35
	andi R24,252
	out 0x35,R24
	.dbline 124
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 125
;    SET_INT1_FALLING_EDGE
	in R24,0x35
	andi R24,243
	out 0x35,R24
	.dbline 125
	in R24,0x35
	ori R24,8
	out 0x35,R24
	.dbline 126
;    GICR |= BIT(INT0)|BIT(INT1);
	in R24,0x3b
	ori R24,192
	out 0x3b,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e INT0_ISR _INT0_ISR fV
	.even
_INT0_ISR::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	st -y,R26
	st -y,R27
	in R0,0x3f
	st -y,R0
	.dbline -1
	.dbline 136
; }
; 
; /***********************************************************
; *   函数说明:外中断0中断处理函数                          *
; *   输入:    无                                           *
; *   输出:    无                                           *
; *   调用函数:INSERT_INT0_ISR_CODE                         *
; ***********************************************************/
; void INT0_ISR(void)
; {
	.dbline 137
;     INSERT_INT0_ISR_CODE
	.dbline 137
	in R24,0x10
	lsr R24
	lsr R24
	andi R24,1
	in R25,0x10
	lsr R25
	lsr R25
	lsr R25
	andi R25,1
	cp R25,R24
	brne L4
X0:
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	sub R2,R24
	sbc R3,R25
	sbc R4,R26
	sbc R5,R27
	sts _g_dNowMotorPosition+1,R3
	sts _g_dNowMotorPosition,R2
	sts _g_dNowMotorPosition+2+1,R5
	sts _g_dNowMotorPosition+2,R4
	rjmp L5
L4:
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	sts _g_dNowMotorPosition+1,R3
	sts _g_dNowMotorPosition,R2
	sts _g_dNowMotorPosition+2+1,R5
	sts _g_dNowMotorPosition+2,R4
L5:
	.dbline 137
	in R24,0x35
	andi R24,3
	cpi R24,3
	brne L6
X1:
	.dbline 137
	.dbline 137
	in R24,0x35
	andi R24,252
	out 0x35,R24
	.dbline 137
	in R24,0x35
	ori R24,2
	out 0x35,R24
	.dbline 137
	rjmp L7
L6:
	.dbline 137
	.dbline 137
	in R24,0x35
	andi R24,252
	out 0x35,R24
	.dbline 137
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 137
L7:
	.dbline 137
	.dbline -2
L3:
	.dbline 0 ; func end
	ld R0,y+
	out 0x3f,R0
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.dbfunc e INT1_ISR _INT1_ISR fV
	.even
_INT1_ISR::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	st -y,R26
	st -y,R27
	in R0,0x3f
	st -y,R0
	.dbline -1
	.dbline 147
; }
; 
; /***********************************************************
; *   函数说明:外中断1中断处理函数                          *
; *   输入:    无                                           *
; *   输出:    无                                           *
; *   调用函数:INSERT_INT0_ISR_CODE                         *
; ***********************************************************/
; void INT1_ISR(void)
; {
	.dbline 148
;     INSERT_INT1_ISR_CODE
	.dbline 148
	in R24,0x10
	lsr R24
	lsr R24
	andi R24,1
	in R25,0x10
	lsr R25
	lsr R25
	lsr R25
	andi R25,1
	cp R25,R24
	brne L9
X2:
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	sts _g_dNowMotorPosition+1,R3
	sts _g_dNowMotorPosition,R2
	sts _g_dNowMotorPosition+2+1,R5
	sts _g_dNowMotorPosition+2,R4
	rjmp L10
L9:
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	lds R4,_g_dNowMotorPosition+2
	lds R5,_g_dNowMotorPosition+2+1
	lds R2,_g_dNowMotorPosition
	lds R3,_g_dNowMotorPosition+1
	sub R2,R24
	sbc R3,R25
	sbc R4,R26
	sbc R5,R27
	sts _g_dNowMotorPosition+1,R3
	sts _g_dNowMotorPosition,R2
	sts _g_dNowMotorPosition+2+1,R5
	sts _g_dNowMotorPosition+2,R4
L10:
	.dbline 148
	in R24,0x35
	andi R24,12
	cpi R24,12
	brne L11
X3:
	.dbline 148
	.dbline 148
	in R24,0x35
	andi R24,243
	out 0x35,R24
	.dbline 148
	in R24,0x35
	ori R24,8
	out 0x35,R24
	.dbline 148
	rjmp L12
L11:
	.dbline 148
	.dbline 148
	in R24,0x35
	andi R24,243
	out 0x35,R24
	.dbline 148
	in R24,0x35
	ori R24,12
	out 0x35,R24
	.dbline 148
L12:
	.dbline 148
	.dbline -2
L8:
	.dbline 0 ; func end
	ld R0,y+
	out 0x3f,R0
	ld R27,y+
	ld R26,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	reti
	.dbend
	.dbfunc s Port_INIT _Port_INIT fV
	.even
_Port_INIT:
	.dbline -1
	.dbline 158
; }
; 
; /***********************************************************
; *   函数说明:系统端口初始化函数                           *
; *   输入:    无                                           *

⌨️ 快捷键说明

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