?? main.s
字號:
.module main.c
.area lit(rom, con, rel)
L2:
.byte 0,0
.byte 0,0
L3:
.byte 0,0
.byte 0,0
.area bss(ram, con, rel)
L4:
.blkb 1
.area text(rom, con, rel)
.dbfile F:\網絡下載\AVR\完整應用\電流電壓表\SOF\main.c
.dbfunc e main _main fI
.dbsym s chdot L4 c
; chS_V -> y+6
; chS_A -> y+2
.even
_main::
sbiw R28,10
.dbline -1
.dbline 33
; //ICC-AVR application builder : 2006-12-28 11:58:18
; // Target : M8
; // Crystal: 4.0000Mhz
; //本程序主要完成對外界輸入的電流/電壓進行AD轉換并顯示的功能
; /*
; * Copyright (c) 2005, 廣州力源電器公司開發部
; * All rights reserved.
; * 文件名稱:main.c 主函數
;
; * 當前版本: 1.0
; * 作者: 張洪強
; * 完成日期: 2005.7.25
; */
;
; #include <iom8v.h>
; #include <macros.h>
; //#include <interrupt.h>
; #include <signal.h>
; //#include <wdt.h>
; #include <stdlib.h>
; #include <eeprom.h>
; #include "init.h"
;
; void convert_v( unsigned char* pch);
; void convert_a( unsigned char* pch);
; void SET_A( unsigned char* pch );
; void CHECK_EDATA_A(void);
;
; //char CS[4] = {0,2,1,0};
;
; int main(void)
; {
.dbline 34
; unsigned char chS_V[]={0,0,0,0},chS_A[]={0,0,0,0};
ldi R24,<L2
ldi R25,>L2
movw R30,R28
adiw R30,6
ldi R16,4
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
st -y,R24
rcall asgncblk
.dbline 34
ldi R24,<L3
ldi R25,>L3
movw R30,R28
adiw R30,2
ldi R16,4
ldi R17,0
st -y,R31
st -y,R30
st -y,R25
rcall asgncblk
.dbline 36
; static unsigned char chdot;
; delayMS(250); //延時250MS
ldi R16,250
rcall _delayMS
.dbline 37
; delayMS(250); //延時250MS
ldi R16,250
rcall _delayMS
.dbline 38
; eeprom_busy_wait();
rcall _eeprom_busy_wait
.dbline 39
; cli();
rcall _cli
.dbline 40
; eeprom_read_block((char*)MAX_A,(char*)0x20,6 );
ldi R24,6
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,32
ldi R19,0
ldi R16,<_MAX_A
ldi R17,>_MAX_A
rcall _eeprom_read_block
.dbline 41
; CHECK_EDATA_A();
rcall _CHECK_EDATA_A
.dbline 42
; init_devices(); //初始化端口
rcall _init_devices
.dbline 44
;
; for (;;)
L5:
.dbline 45
; {
.dbline 46
; wdt_reset(); //喂狗
rcall _wdt_reset
.dbline 47
; convert_v( chS_V );
movw R16,R28
subi R16,250 ; offset = 6
sbci R17,255
rcall _convert_v
.dbline 48
; convert_a( chS_A );
movw R16,R28
subi R16,254 ; offset = 2
sbci R17,255
rcall _convert_a
.dbline 49
; key_board();
rcall _key_board
.dbline 50
; if ( !SET_STATU )
lds R2,_SET_STATU
tst R2
brne L9
.dbline 51
; {
.dbline 52
; if ( KEY_A_V_STATE )
lds R2,_KEY_A_V_STATE
tst R2
breq L11
.dbline 53
; {
.dbline 54
; if ( MAX_A[0] >= 500 )
lds R24,_MAX_A
lds R25,_MAX_A+1
cpi R24,244
ldi R30,1
cpc R25,R30
brlo L13
.dbline 55
; {
.dbline 56
; chdot = NODOT;
ldi R24,64
sts L4,R24
.dbline 57
; }
rjmp L14
L13:
.dbline 59
; else
; {
.dbline 60
; chdot = ONEDOT;
ldi R24,1
sts L4,R24
.dbline 61
; }
L14:
.dbline 62
; display(chS_A,chdot); //顯示電流值
lds R18,L4
movw R16,R28
subi R16,254 ; offset = 2
sbci R17,255
rcall _display
.dbline 63
; }
rjmp L5
L11:
.dbline 65
; else
; {
.dbline 66
; chdot = TWODOT;
ldi R24,2
sts L4,R24
.dbline 67
; display(chS_V,chdot); //顯示電壓值
mov R18,R24
movw R16,R28
subi R16,250 ; offset = 6
sbci R17,255
rcall _display
.dbline 68
; }
.dbline 69
; }
rjmp L5
L9:
.dbline 71
.dbline 72
movw R16,R28
subi R16,254 ; offset = 2
sbci R17,255
rcall _SET_A
.dbline 73
ldi R24,64
sts L4,R24
.dbline 74
mov R18,R24
movw R16,R28
subi R16,254 ; offset = 2
sbci R17,255
rcall _display
.dbline 75
.dbline 77
.dbline 44
.dbline 44
rjmp L5
X0:
.dbline -2
L1:
adiw R28,10
.dbline 0 ; func end
ret
.dbsym l chS_V 6 A[4:4]c
.dbsym l chS_A 2 A[4:4]c
.dbend
.dbfunc e convert_v _convert_v fV
; intV -> R20,R21
; i -> R22,R23
; pch -> R10,R11
.even
_convert_v::
rcall push_gset3
movw R10,R16
.dbline -1
.dbline 81
; else
; {
; SET_A( chS_A ); //進入設置電流值狀態
; chdot = NODOT;
; display(chS_A,chdot); //顯示設定電流值
; }
; //delayMS(10); //延時10MS
; }
; }
;
; void convert_v( unsigned char* pch )
; {
.dbline 83
; unsigned int intV,i;
; intV = (int) (((float)MAX_V * (float) adc_data[0]) /1024.0) ;
ldi R16,<L16
ldi R17,>L16
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_adc_data+2
lds R5,_adc_data+2+1
lds R2,_adc_data
lds R3,_adc_data+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
rcall empy32fs
ldi R16,<L17
ldi R17,>L17
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall div32f
rcall fp2int
movw R20,R16
.dbline 85
; //計算電壓值
; if ( intV > 70 )
ldi R24,70
ldi R25,0
cp R24,R16
cpc R25,R17
brsh L18
.dbline 86
; {
.dbline 87
; intV -= 70;
subi R20,70
sbci R21,0
.dbline 88
; }
rjmp L19
L18:
.dbline 90
; else
; {
.dbline 91
; intV = 0;
clr R20
clr R21
.dbline 92
; }
L19:
.dbline 93
; for ( i = 0; i < 4; i++ )
clr R22
clr R23
rjmp L23
L20:
.dbline 94
.dbline 95
ldi R18,10
ldi R19,0
movw R16,R20
rcall mod16u
movw R30,R22
add R30,R10
adc R31,R11
std z+0,R16
.dbline 96
ldi R18,10
ldi R19,0
movw R16,R20
rcall div16u
movw R20,R16
.dbline 97
L21:
.dbline 93
subi R22,255 ; offset = 1
sbci R23,255
L23:
.dbline 93
cpi R22,4
ldi R30,0
cpc R23,R30
brlo L20
.dbline -2
L15:
rcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r intV 20 i
.dbsym r i 22 i
.dbsym r pch 10 pc
.dbend
.dbfunc e convert_a _convert_a fV
; k -> R10,R11
; temp -> y+4
; intA -> y+0
; n -> R12,R13
; i -> R14,R15
; pch -> y+22
.even
_convert_a::
st -y,r17
st -y,r16
rcall push_gset5
sbiw R28,12
.dbline -1
.dbline 101
; {
; pch[i] = intV % 10;
; intV /= 10;
; }
; }
;
; void convert_a( unsigned char* pch)
; {
.dbline 103
; unsigned int i,n,k;
; float temp = 0,intA;
ldi R16,<L25
ldi R17,>L25
rcall lpm32
movw R30,R28
std z+4,R16
std z+5,R17
std z+6,R18
std z+7,R19
.dbline 104
; CHECK_EDATA_A();
rcall _CHECK_EDATA_A
.dbline 105
; if ( MAX_A[0] < 500 )
lds R24,_MAX_A
lds R25,_MAX_A+1
cpi R24,244
ldi R30,1
cpc R25,R30
brsh L26
.dbline 106
; {
.dbline 107
; k = 10;
ldi R24,10
ldi R25,0
movw R10,R24
.dbline 108
; }
rjmp L27
L26:
.dbline 110
; else
; {
.dbline 111
; k = 1;
ldi R24,1
ldi R25,0
movw R10,R24
.dbline 112
; }
L27:
.dbline 113
; intA = ((float)MAX_A[0] * 2.0 * k * adc_data[1]) / 1024.0;
ldi R16,<L29
ldi R17,>L29
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
ldi R16,<L30
ldi R17,>L30
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R16,_MAX_A
lds R17,_MAX_A+1
lsr R17
ror R16
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall empy32fs
lds R16,_MAX_A
lds R17,_MAX_A+1
andi R16,1
andi R17,0
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall add32fs
rcall empy32fs
ldi R16,<L30
ldi R17,>L30
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R10
lsr R17
ror R16
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall empy32fs
movw R16,R10
andi R16,1
andi R17,0
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall add32fs
rcall empy32fs
lds R4,_adc_data+4+2
lds R5,_adc_data+4+2+1
lds R2,_adc_data+4
lds R3,_adc_data+4+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
rcall empy32fs
ldi R16,<L17
ldi R17,>L17
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall div32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 116
; //計算電流值
;
; temp = (float)MAX_A[0]* 7.93 * k / 100.0 ;
ldi R16,<L31
ldi R17,>L31
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
ldi R16,<L30
ldi R17,>L30
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R16,_MAX_A
lds R17,_MAX_A+1
lsr R17
ror R16
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall empy32fs
lds R16,_MAX_A
lds R17,_MAX_A+1
andi R16,1
andi R17,0
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall add32fs
rcall empy32fs
ldi R16,<L30
ldi R17,>L30
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R16,R10
lsr R17
ror R16
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall empy32fs
movw R16,R10
andi R16,1
andi R17,0
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall add32fs
rcall empy32fs
ldi R16,<L32
ldi R17,>L32
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall div32f
movw R30,R28
std z+4,R16
std z+5,R17
std z+6,R18
std z+7,R19
.dbline 118
;
; if ( intA > temp )
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
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
rcall cmp32f
brlt X1
rjmp L33
X1:
.dbline 119
; {
.dbline 120
; intA -= temp;
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
movw R30,R28
; stack offset 4
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
rcall sub32f
movw R30,R28
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
.dbline 121
; if( adc_data[1] < 33)
lds R4,_adc_data+4+2
lds R5,_adc_data+4+2+1
lds R2,_adc_data+4
lds R3,_adc_data+4+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L38
ldi R17,>L38
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall cmp32f
brlt X2
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -