📄 proc_communication.s
字号:
.module PROC_Communication.c
.area text(rom, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
_g_bIfBrake::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
_g_cSpeed::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
_g_wDistance::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
L2:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
L3:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
.blkb 4
.area idata
.byte 0,0,0,0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
L4:
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
.area text(rom, con, rel)
.dbfile H:\单片机\源程序\2007全国电子设计大赛\电机闭环模块\PROC_Communication.c
.dbfunc e PROC_Command_Check _PROC_Command_Check fc
.dbsym s cXORCheck L4 c
.dbsym s cBytes L3 A[5:5]c
.dbsym s cByteCounter L2 c
; cData -> y+5
.even
_PROC_Command_Check::
st -y,R20
st -y,R21
sbiw R28,6
.dbline -1
.dbline 74
; /***********************************************************
; * 函数库说明:电机闭环位置控制模块通讯函数库 *
; * 版本: v1.00 *
; * 作者: 王卓然 *
; * 创建日期: 2007年9月03日 *
; * -------------------------------------------------------- *
; * [支 持 库] *
; * 支持库名称: *
; * 需要版本: *
; * 支持库说明: *
; * -------------------------------------------------------- *
; * [版本更新] *
; * 修改: *
; * 修改日期: *
; * 版本: *
; * -------------------------------------------------------- *
; * [版本历史] *
; * -------------------------------------------------------- *
; * [使用说明] *
; ***********************************************************/
;
; /********************
; * 头 文 件 配 置 区 *
; ********************/
; # include "LIB_Config.h"
; # include "PF_Config.h"
; # include "PROC_Communication.h"
;
; /********************
; * 系 统 宏 定 义 *
; ********************/
;
; /*------------------*
; * 常 数 宏 定 义 *
; *------------------*/
;
; /*------------------*
; * 动 作 宏 定 义 *
; *------------------*/
;
;
; /********************
; * 结构体定义区 *
; ********************/
;
;
; /********************
; * 模块函数声明区 *
; ********************/
;
; /********************
; * 全局函数声明区 *
; ********************/
; BOOL PROC_Command_Check(void);
;
; /********************
; * 模块变量声明区 *
; ********************/
;
; /********************
; * 全局变量声明区 *
; ********************/
; BOOL g_bIfBrake = FALSE;
; int8 g_cSpeed = 0;
; uint16 g_wDistance = 0;
;
; /***********************************************************
; * 函数说明:数据帧接收函数 *
; * 输入: 无 *
; * 输出: 无 *
; * 调用函数:无 *
; ***********************************************************/
; BOOL PROC_Command_Check(void)
; {
.dbline 75
; uint8 cData = 0;
clr R2
std y+5,R2
.dbline 80
; static uint8 cByteCounter = 0;
; static uint8 cBytes[sizeof(CMD_FRAME)+1] = {0};
; static uint8 cXORCheck = 0;
;
; if (!SERIAL_IN(cData))
movw R16,R28
subi R16,251 ; offset = 5
sbci R17,255
rcall _UARTgetDataFromRxBuff
tst R16
brne L5
X0:
.dbline 81
; {
.dbline 82
; return TRUE;
ldi R16,1
rjmp L1
L5:
.dbline 95
; }
; /*
; Set_DISP_BUFF
; (
; ABS(cData)>>4,
; ABS(cData)&0x0f,
; SET_WORD_DIV_4(g_wDistance).BYTEAH,
; SET_WORD_DIV_4(g_wDistance).BYTEAH,
; SET_WORD_DIV_4(g_wDistance).BYTEAL
; );
; */
; //接收到了数据
; switch (cByteCounter)
lds R20,L2
tst R20
breq L10
X1:
cpi R20,0
brsh X8
rjmp L7
X8:
X2:
L25:
cpi R20,5
breq L13
X3:
rjmp L7
L10:
.dbline 98
; {
; case 0:
; if (cData == 0xAA)
ldd R24,y+5
cpi R24,170
breq X9
rjmp L8
X9:
X4:
.dbline 99
; {
.dbline 100
; cBytes[0] = 0xAA;
ldi R24,170
sts L3,R24
.dbline 101
; cByteCounter++;
lds R24,L2
subi R24,255 ; addi 1
sts L2,R24
.dbline 102
; cXORCheck = 0xAA;
ldi R24,170
sts L4,R24
.dbline 103
; }
.dbline 104
; break;
rjmp L8
L13:
.dbline 106
; case UBOUND(cBytes):
; if (cData == cXORCheck)
lds R2,L4
ldd R3,y+5
cp R3,R2
breq X10
rjmp L14
X10:
X5:
.dbline 107
; {
.dbline 109
; //数据帧正确
; g_bIfBrake = TYPE_CONVERSION(&cBytes[1],CMD_FRAME).IfBrake;
ldi R30,<L3+1
ldi R31,>L3+1
ldd R24,z+0
ldd R25,z+1
andi R24,1
andi R25,0
sts _g_bIfBrake,R24
.dbline 111
; #ifndef LEFT_MOTOR
; g_cSpeed = TYPE_CONVERSION(&cBytes[1],CMD_FRAME).Speed;
lds R2,L3+1+1
sts _g_cSpeed,R2
.dbline 115
; #else
; g_cSpeed = -(TYPE_CONVERSION(&cBytes[1],CMD_FRAME).Speed);
; #endif
; g_wDistance = TYPE_CONVERSION(&cBytes[1],CMD_FRAME).Distance;
lds R24,L3+1+2
lds R25,L3+1+2+1
andi R25,127
sts _g_wDistance+1,R25
sts _g_wDistance,R24
.dbline 118
;
;
; Set_DISP_BUFF
lds R24,_g_wDistance
lds R25,_g_wDistance+1
andi R24,15
andi R25,0
std y+4,R24
lds R24,_g_wDistance
lds R25,_g_wDistance+1
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
andi R24,15
andi R25,0
std y+2,R24
lds R24,_g_wDistance
lds R25,_g_wDistance+1
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
lsr R25
ror R24
andi R24,15
andi R25,0
std y+0,R24
mov R24,R2
cpi R24,0
brge L21
X6:
mov R20,R24
clr R21
sbrc R20,7
com R21
com R20
com R21
subi R20,0xFF
sbci R21,0xFF
rjmp L22
L21:
lds R20,_g_cSpeed
clr R21
sbrc R20,7
com R21
L22:
mov R18,R20
andi R18,15
andi R19,0
lds R24,_g_cSpeed
cpi R24,0
brge L23
X7:
mov R20,R24
clr R21
sbrc R20,7
com R21
com R20
com R21
subi R20,0xFF
sbci R21,0xFF
rjmp L24
L23:
lds R20,_g_cSpeed
clr R21
sbrc R20,7
com R21
L24:
movw R16,R20
asr R17
ror R16
asr R17
ror R16
asr R17
ror R16
asr R17
ror R16
rcall _Set_DISP_BUFF
.dbline 127
; (
; ABS(g_cSpeed)>>4,
; ABS(g_cSpeed)&0x0f,
; SET_WORD_DIV_4(g_wDistance).BYTEAH,
; SET_WORD_DIV_4(g_wDistance).BYTEAH,
; SET_WORD_DIV_4(g_wDistance).BYTEAL
; );
;
; }
L14:
.dbline 128
; cByteCounter = 0; //复位计数器
clr R2
sts L2,R2
.dbline 129
; cXORCheck = 0;
sts L4,R2
.dbline 131
;
; break;
rjmp L8
L7:
.dbline 133
; default:
; cBytes[cByteCounter++] = cData;
lds R2,L2
mov R24,R2
subi R24,255 ; addi 1
sts L2,R24
ldi R24,<L3
ldi R25,>L3
mov R30,R2
clr R31
add R30,R24
adc R31,R25
ldd R2,y+5
std z+0,R2
.dbline 134
; cXORCheck ^= cData;
lds R3,L4
eor R3,R2
sts L4,R3
.dbline 135
; break;
L8:
.dbline 138
; }
;
; return TRUE;
ldi R16,1
.dbline -2
L1:
.dbline 0 ; func end
adiw R28,6
ld R21,y+
ld R20,y+
ret
.dbsym l cData 5 c
.dbend
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -