📄 main.s
字号:
L38:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r Y 22 c
.dbsym r X 20 c
.dbend
.dbfunc s LcdSend _LcdSend fV
; command -> R18
; data -> R16
.even
_LcdSend:
.dbline -1
.dbline 209
; }
;
; /*--------------------------------------------------------------------------------------------------
; Name : LcdSend
; Description : Sends data to display controller.
; Argument(s) : data -> Data to be sent
; cd -> Command or data (see/use enum)
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; static void LcdSend (unsigned char data, unsigned char command)
; {
.dbline 210
; PORTB &= ~LCD_CE_PIN ; // 使能LCD
cbi 0x18,1
.dbline 211
; if (command == 0)
tst R18
brne L40
.dbline 212
; PORTB &= ~LCD_DC_PIN ; // 传送命令
cbi 0x18,2
xjmp L41
L40:
.dbline 214
; else
; PORTB |= LCD_DC_PIN ; // 传送数据
sbi 0x18,2
L41:
.dbline 216
;
; SPDR = data; // 传送数据到SPI寄存器
out 0xf,R16
L42:
.dbline 218
L43:
.dbline 218
;
; while ((SPSR & 0x80) == 0); // 等待数据传送完毕
sbis 0xe,7
rjmp L42
.dbline 220
;
; PORTB |= LCD_CE_PIN ; // 关闭LCD
sbi 0x18,1
.dbline -2
L39:
.dbline 0 ; func end
ret
.dbsym r command 18 c
.dbsym r data 16 c
.dbend
.dbfunc s Delay _Delay fV
; i -> R16,R17
.even
_Delay:
.dbline -1
.dbline 229
; }
; /*--------------------------------------------------------------------------------------------------
; Name : Delay
; Description : Uncalibrated delay for LCD init routine.
; Argument(s) : None.
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; static void Delay ( void )
; {
.dbline 231
ldi R16,-12000
ldi R17,-47
L46:
.dbline 231
L47:
.dbline 231
; int i;
; for ( i = -12000; i < 12000; i++ );
subi R16,255 ; offset = 1
sbci R17,255
.dbline 231
cpi R16,224
ldi R30,46
cpc R17,R30
brlt L46
.dbline -2
L45:
.dbline 0 ; func end
ret
.dbsym r i 16 I
.dbend
.dbfunc e lcd_show _lcd_show fV
; tmp -> R20
; i -> R22
; DOT -> R10,R11
; r -> R12,R13
.even
_lcd_show::
xcall push_gset4
movw R10,R18
movw R12,R16
.dbline -1
.dbline 235
; }
;
; void lcd_show(unsigned int r,unsigned int DOT)
; {
.dbline 236
; unsigned char tmp=0,i=0;
clr R20
.dbline 236
clr R22
.dbline 237
; if(r >1000)
ldi R24,1000
ldi R25,3
cp R24,R12
cpc R25,R13
brsh L51
.dbline 238
; {
.dbline 239
; tmp=r/1000;
ldi R18,1000
ldi R19,3
movw R16,R12
xcall div16u
mov R20,R16
.dbline 240
; for(i=0;i<5;i++)
xjmp L56
L53:
.dbline 241
ldi R18,1
ldi R24,5
mul R24,R20
movw R2,R0
ldi R24,<_FontLookup
ldi R25,>_FontLookup
add R2,R24
adc R3,R25
mov R30,R22
clr R31
add R30,R2
adc R31,R3
lpm R16,Z
xcall _LcdSend
L54:
.dbline 240
inc R22
L56:
.dbline 240
cpi R22,5
brlo L53
.dbline 242
; LcdSend(FontLookup[tmp][i],1);
; }
L51:
.dbline 243
; if(r >100)
ldi R24,100
ldi R25,0
cp R24,R12
cpc R25,R13
brsh L57
.dbline 244
; {
.dbline 245
; tmp=(r%1000)/100;
ldi R18,1000
ldi R19,3
movw R16,R12
xcall mod16u
ldi R18,100
ldi R19,0
xcall div16u
mov R20,R16
.dbline 246
; for(i=0;i<5;i++)
clr R22
xjmp L62
L59:
.dbline 247
ldi R18,1
ldi R24,5
mul R24,R20
movw R2,R0
ldi R24,<_FontLookup
ldi R25,>_FontLookup
add R2,R24
adc R3,R25
mov R30,R22
clr R31
add R30,R2
adc R31,R3
lpm R16,Z
xcall _LcdSend
L60:
.dbline 246
inc R22
L62:
.dbline 246
cpi R22,5
brlo L59
.dbline 248
; LcdSend(FontLookup[tmp][i],1);
; }
L57:
.dbline 249
; if(r >10)
ldi R24,10
ldi R25,0
cp R24,R12
cpc R25,R13
brsh L63
.dbline 250
; {
.dbline 251
; tmp=(r%100)/10;
ldi R18,100
ldi R19,0
movw R16,R12
xcall mod16u
ldi R18,10
ldi R19,0
xcall div16u
mov R20,R16
.dbline 252
; for(i=0;i<5;i++)
clr R22
xjmp L68
L65:
.dbline 253
ldi R18,1
ldi R24,5
mul R24,R20
movw R2,R0
ldi R24,<_FontLookup
ldi R25,>_FontLookup
add R2,R24
adc R3,R25
mov R30,R22
clr R31
add R30,R2
adc R31,R3
lpm R16,Z
xcall _LcdSend
L66:
.dbline 252
inc R22
L68:
.dbline 252
cpi R22,5
brlo L65
.dbline 254
; LcdSend(FontLookup[tmp][i],1);
; }
L63:
.dbline 256
;
; tmp=r%10;
ldi R18,10
ldi R19,0
movw R16,R12
xcall mod16u
mov R20,R16
.dbline 258
;
; for(i=0;i<5;i++)
clr R22
xjmp L72
L69:
.dbline 259
ldi R18,1
ldi R24,5
mul R24,R20
movw R2,R0
ldi R24,<_FontLookup
ldi R25,>_FontLookup
add R2,R24
adc R3,R25
mov R30,R22
clr R31
add R30,R2
adc R31,R3
lpm R16,Z
xcall _LcdSend
L70:
.dbline 258
inc R22
L72:
.dbline 258
cpi R22,5
brlo L69
.dbline 261
; LcdSend(FontLookup[tmp][i],1);
; // 小数点
; for(i=0;i<5;i++)
clr R22
xjmp L76
L73:
.dbline 262
ldi R18,1
ldi R24,<_FontLookup+50
ldi R25,>_FontLookup+50
mov R30,R22
clr R31
add R30,R24
adc R31,R25
lpm R16,Z
xcall _LcdSend
L74:
.dbline 261
inc R22
L76:
.dbline 261
cpi R22,5
brlo L73
.dbline 264
; LcdSend(FontLookup[10][i],1);
; //
; for(i=0;i<5;i++)
clr R22
xjmp L81
L78:
.dbline 265
ldi R18,1
ldi R16,5
ldi R17,0
push R18
push R19
movw R18,R10
xcall empy16s
movw R2,R16
pop R19
pop R18
ldi R24,<_FontLookup
ldi R25,>_FontLookup
add R2,R24
adc R3,R25
mov R30,R22
clr R31
add R30,R2
adc R31,R3
lpm R16,Z
xcall _LcdSend
L79:
.dbline 264
inc R22
L81:
.dbline 264
cpi R22,5
brlo L78
.dbline 267
; LcdSend(FontLookup[DOT][i],1);
; //K
; for(i=0;i<5;i++)
clr R22
xjmp L85
L82:
.dbline 268
ldi R18,1
ldi R24,<_FontLookup+55
ldi R25,>_FontLookup+55
mov R30,R22
clr R31
add R30,R24
adc R31,R25
lpm R16,Z
xcall _LcdSend
L83:
.dbline 267
inc R22
L85:
.dbline 267
cpi R22,5
brlo L82
.dbline -2
L50:
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r tmp 20 c
.dbsym r i 22 c
.dbsym r DOT 10 i
.dbsym r r 12 i
.dbend
.dbfunc e main _main fV
; RF -> y+4
; DOT -> R22,R23
; time2 -> R12,R13
; time1 -> R14,R15
; R_TMP -> R20,R21
; R -> y+0
.even
_main::
sbiw R28,12
.dbline -1
.dbline 292
; LcdSend(FontLookup[11][i],1);
; }
;
;
; /*--------------------------------------------------------------------------------------------------
; Name : main
; Description :
; Argument(s) :
; Return value : None.
; --------------------------------------------------------------------------------------------------*/
; /*
; void main(void)
; { unsigned char X; //v=0,按行显示,x对应某个bank(0~83)
; LcdInit();
;
; while(1)
; {
; LcdGotoXY(X_Init,Y_Init);
; for(X=0;X<X_Length;X++)LcdSend(X_TAB[X],1);
; }
; }
; */
;
; void main(void)
; {
.dbline 293
; unsigned int time1=0,time2=0;
clr R14
clr R15
.dbline 293
clr R12
clr R13
.dbline 294
; float RF=46.0,R=0.0;
ldi R16,<L88
ldi R17,>L88
xcall lpm32
movw R30,R28
std z+4,R16
std z+5,R17
std z+6,R18
std z+7,R19
.dbline 294
ldi R16,<L89
ldi R17,>L89
xcall lpm32
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 295
; unsigned int R_TMP=0,DOT=0;
clr R20
clr R21
.dbline 295
clr R22
clr R23
.dbline 296
; timer_count=0;
clr R2
clr R3
sts _timer_count+1,R3
sts _timer_count,R2
.dbline 298
;
; init_devices(); //全部输入,内部上拉
xcall _init_devices
.dbline 300
;
; DDRA |=(1<<2);
sbi 0x1a,2
.dbline 301
; PORTA |=(1<<2); //PA2 输出,完成充电
sbi 0x1b,2
.dbline 302
; Delay1s(1); //延时等待充满
ldi R16,1
ldi R17,0
xcall _Delay1s
.dbline 303
; _NOP();
nop
.dbline 304
; DDRA &=~(1<<2); //输入,
cbi 0x1a,2
.dbline 305
; PORTA &=~(1<<2);
cbi 0x1b,2
.dbline 307
;
; timer0_init();
xcall _timer0_init
.dbline 308
; DDRA |=(1<<1); //
sbi 0x1a,1
.dbline 309
; PORTA &=~(1<<1); //PA1 输出低,完成放电
cbi 0x1b,1
L90:
.dbline 310
L91:
.dbline 310
; while(PINA&(1<<2)); //等待,放电完成,PINA2被拉低
sbic 0x19,2
rjmp L90
.dbline 311
; TCCR0 = 0x00; //stop timer
clr R2
out 0x33,R2
.dbline 312
; time1=timer_count; //记录标准电阻的放电时间
lds R14,_timer_count
lds R15,_timer_count+1
.dbline 315
;
;
; timer_count=0;
clr R3
sts _timer_count+1,R3
sts _timer_count,R2
.dbline 316
; init_devices(); //全部输入,内部上拉
xcall _init_devices
.dbline 317
; DDRA |=(1<<2);
sbi 0x1a,2
.dbline 318
; PORTA |=(1<<2); //PA2 输出,完成充电
sbi 0x1b,2
.dbline 319
; Delay1s(1); //延时等待充满
ldi R16,1
ldi R17,0
xcall _Delay1s
.dbline 320
; _NOP();
nop
.dbline 321
; DDRA &=~(1<<2); //输入
cbi 0x1a,2
.dbline 322
; PORTA &=~(1<<2); //清内部上拉
cbi 0x1b,2
.dbline 324
;
; timer0_init();
xcall _timer0_init
.dbline 325
; DDRA |=(1<<0); //
sbi 0x1a,0
.dbline 326
; PORTA &=~(1<<0); //PA0 输出低,完成放电
cbi 0x1b,0
L93:
.dbline 327
L94:
.dbline 327
; while(PINA&(1<<2)); //等待,让电完成,PINA2被拉低
sbic 0x19,2
rjmp L93
.dbline 328
; TCCR0 = 0x00; //stop timer
clr R2
out 0x33,R2
.dbline 329
; time2=timer_count; //计算待测电阻的时间
lds R12,_timer_count
lds R13,_timer_count+1
.dbline 332
;
; //开始计算阻值
; R=RF*time2/time1;
movw R30,R28
ldd R2,z+4
ldd R3,z+5
ldd R4,z+6
ldd R5,z+7
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L96
ldi R17,>L96
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R12
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
movw R16,R12
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32fs
xcall empy32fs
ldi R16,<L96
ldi R17,>L96
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R14
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
movw R16,R14
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32fs
xcall div32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 335
;
; //R=1234;
; LcdInit();
xcall _LcdInit
.dbline 336
; LcdGotoXY(X_Init,Y_Init);
ldi R18,2
ldi R16,10
xcall _LcdGotoXY
.dbline 338
;
; R_TMP=R;
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L99
ldi R17,>L99
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L97
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L99
ldi R17,>L99
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R24,R16
subi R24,0 ; offset = 32768
sbci R25,128
movw R10,R24
xjmp L98
L97:
movw R30,R28
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
xcall fp2int
movw R10,R16
L98:
movw R20,R10
.dbline 339
; DOT=(R-R_TMP)*10;
ldi R16,<L102
ldi R17,>L102
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+4
ldd R3,z+5
ldd R4,z+6
ldd R5,z+7
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L96
ldi R17,>L96
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R20
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
movw R16,R20
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32fs
xcall sub32fs
xcall empy32f
movw R30,R28
std z+8,R16
std z+9,R17
std z+10,R18
std z+11,R19
movw R30,R28
ldd R2,z+8
ldd R3,z+9
ldd R4,z+10
ldd R5,z+11
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L99
ldi R17,>L99
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L100
movw R30,R28
ldd R2,z+8
ldd R3,z+9
ldd R4,z+10
ldd R5,z+11
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L99
ldi R17,>L99
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R24,R16
subi R24,0 ; offset = 32768
sbci R25,128
movw R10,R24
xjmp L101
L100:
movw R30,R28
ldd R16,z+8
ldd R17,z+9
ldd R18,z+10
ldd R19,z+11
xcall fp2int
movw R10,R16
L101:
movw R22,R10
.dbline 340
; lcd_show(R_TMP,DOT);
movw R18,R22
movw R16,R20
xcall _lcd_show
L103:
.dbline 343
L104:
.dbline 342
xjmp L103
X3:
.dbline -2
L87:
adiw R28,12
.dbline 0 ; func end
ret
.dbsym l RF 4 D
.dbsym r DOT 22 i
.dbsym r time2 12 i
.dbsym r time1 14 i
.dbsym r R_TMP 20 i
.dbsym l R 0 D
.dbend
.area lit(rom, con, rel)
L102:
.word 0x0,0x4120
L99:
.word 0x0,0x4700
L96:
.word 0x0,0x4000
L89:
.word 0x0,0x0
L88:
.word 0x0,0x4238
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -