📄 ledtest.s
字号:
.module ledtest.c
.area data(ram, con, rel)
_I_Timer::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\ICC128\2008控制台\2008console0TEST\U盘扇区读写\ledtest.c
.dbsym e I_Timer _I_Timer I
.area text(rom, con, rel)
.dbfile E:\ICC128\2008控制台\2008console0TEST\U盘扇区读写\ledtest.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 14
;
; //ICC-AVR application builder : 2008-1-23 9:13:29
; // Target : M128
; // Crystal: 8.0000Mhz
; //#include <iom128v.h>
; //#include <macros.h>
; #include "2008.h"
;
; int I_Timer=0;
;
; //#define portout (*(volatile unsigned char*)0x1100)
;
; void port_init(void)
; {
.dbline 15
; PORTA = 0XFF;
ldi R24,255
out 0x1b,R24
.dbline 16
; DDRA = 0XFF;
out 0x1a,R24
.dbline 17
; PORTF = 0XFF;
sts 98,R24
.dbline 18
; DDRF = 0XFF;
sts 97,R24
.dbline 19
; PORTB = 0xFF;
out 0x18,R24
.dbline 20
; DDRB = 0xF7;
ldi R24,247
out 0x17,R24
.dbline 21
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 22
; DDRD = 0xE3;
ldi R24,227
out 0x11,R24
.dbline 23
; PORTE = 0xFF;
ldi R24,255
out 0x3,R24
.dbline 24
; DDRE = 0xFF;
out 0x2,R24
.dbline 25
; PORTG = 0XFF;
sts 101,R24
.dbline 26
; DDRG = 0Xf7;
ldi R24,247
sts 100,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 34
; }
;
; //TIMER0 initialize - prescale:1024
; // WGM: Normal
; // desired value: 20mSec
; // actual value: 19.968mSec (0.2%)
; void timer0_init(void)
; {
.dbline 35
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 36
; ASSR = 0x00; //set async mode
out 0x30,R2
.dbline 37
; TCNT0 = 0x64; //set count
ldi R24,100
out 0x32,R24
.dbline 38
; OCR0 = 0x9C;
ldi R24,156
out 0x31,R24
.dbline 39
; TCCR0 = 0x07; //start timer
ldi R24,7
out 0x33,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 64
jmp _timer0_ovf_isr
.area text(rom, con, rel)
.dbfile E:\ICC128\2008控制台\2008console0TEST\U盘扇区读写\ledtest.c
.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
.even
_timer0_ovf_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
st -y,R30
in R2,0x3f
st -y,R2
.dbline -1
.dbline 44
; }
;
; #pragma interrupt_handler timer0_ovf_isr:17
; void timer0_ovf_isr(void)
; {
.dbline 45
; I_Timer++;
lds R24,_I_Timer
lds R25,_I_Timer+1
adiw R24,1
sts _I_Timer+1,R25
sts _I_Timer,R24
.dbline 46
; if(I_Timer == 50)
cpi R24,50
ldi R30,0
cpc R25,R30
brne L4
.dbline 47
; {
.dbline 48
; PORTG ^= 0x10;
ldi R24,16
lds R2,101
eor R2,R24
sts 101,R2
.dbline 49
; I_Timer =0;
clr R2
clr R3
sts _I_Timer+1,R3
sts _I_Timer,R2
.dbline 50
; }
L4:
.dbline 51
; TCNT0 = 0x64; //reload counter value
ldi R24,100
out 0x32,R24
.dbline -2
L3:
ld R2,y+
out 0x3f,R2
ld R30,y+
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 56
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 58
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 59
; XDIV = 0x00; //xtal divider
clr R2
out 0x3c,R2
.dbline 60
; XMCRA = 0x00; //external memory
sts 109,R2
.dbline 61
; port_init();
xcall _port_init
.dbline 63
; //timer0_init();
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 64
; EICRA = 0x00; //extended ext ints
sts 106,R2
.dbline 65
; EICRB = 0x00; //extended ext ints
out 0x3a,R2
.dbline 66
; EIMSK = 0x00;
out 0x39,R2
.dbline 68
; //TIMSK = 0x01; //timer interrupt sources
; ETIMSK = 0x00; //extended timer interrupt sources
sts 125,R2
.dbline 69
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e initLCDM _initLCDM fV
.even
_initLCDM::
.dbline -1
.dbline 93
; //all peripherals are now initialized
; }
; /*void main()
; {
; int i;
; unsigned char readXDIV;
;
; init_devices();
; initLCDM(); //初始化LCD
; Welcome_interface(); //显示欢迎界面
; for ( i=1; i<=48;i++)
; {
; PORTG &= 0x04;
; PORTG ^= 0X01;
; PORTG ^= 0x02;
; }
; while(1)
; {
; ;// portout = 0xaa;
; }
; }*/
; //============================
; void initLCDM(void)
; {
.dbline 94
; PORTF |= 0XFF;
lds R24,98
ori R24,255
sts 98,R24
.dbline 95
; SetCS;
sbi 0x12,6
.dbline 95
.dbline 96
; SetRD;
sbi 0x12,5
.dbline 96
.dbline 97
; SetWR;
sbi 0x12,7
.dbline 97
.dbline 98
; SetRS;
sbi 0x3,0
.dbline 98
.dbline 105
; // SetRST;
; //delay_ms(30);
; //ClrRST;
; //delay_ms(800);
; // SetRST;
; //delay_ms(10);//
; SdCmd(0xa0,0x07); LCD_ChkBusy(); //使能 BUSY 输出
ldi R18,7
ldi R19,0
ldi R16,160
ldi R17,0
xcall _SdCmd
.dbline 105
xcall _LCD_ChkBusy
.dbline 106
; SdCmd(0x81,0x40); LCD_ChkBusy(); //by default
ldi R18,64
ldi R19,0
ldi R16,129
ldi R17,0
xcall _SdCmd
.dbline 106
xcall _LCD_ChkBusy
.dbline 107
; SdCmd(0x00,0xCD); LCD_ChkBusy(); //Whole Chip LCD Controller Reg(Char Mode)
ldi R18,205
ldi R19,0
clr R16
clr R17
xcall _SdCmd
.dbline 107
xcall _LCD_ChkBusy
.dbline 108
; SdCmd(0x01,0xf2); LCD_ChkBusy(); //BUSY=HiPolity, ClockOut=enable, InternalFreq=4MHz
ldi R18,242
ldi R19,0
ldi R16,1
ldi R17,0
xcall _SdCmd
.dbline 108
xcall _LCD_ChkBusy
.dbline 109
; SdCmd(0x10,0x29); LCD_ChkBusy(); //Whole Chip Cursor Control Reg(disable cursor)
ldi R18,41
ldi R19,0
ldi R16,16
ldi R17,0
xcall _SdCmd
.dbline 109
xcall _LCD_ChkBusy
.dbline 110
; SdCmd(0x11,0x10); LCD_ChkBusy(); //Distance of Words or Lines Reg(cursor=1,gap=0)
ldi R18,16
ldi R19,0
ldi R16,17
ldi R17,0
xcall _SdCmd
.dbline 110
xcall _LCD_ChkBusy
.dbline 111
; SdCmd(0x90,0x05); LCD_ChkBusy(); //Shift Clock Control Reg(320x240,69Hz)
ldi R18,5
ldi R19,0
ldi R16,144
ldi R17,0
xcall _SdCmd
.dbline 111
xcall _LCD_ChkBusy
.dbline 112
; SdCmd(0xf0,0xa0); LCD_ChkBusy(); //Font Control Reg
ldi R18,160
ldi R19,0
ldi R16,240
ldi R17,0
xcall _SdCmd
.dbline 112
xcall _LCD_ChkBusy
.dbline 113
; SdCmd(0xf1,0x0f); LCD_ChkBusy(); //设置字型大小
ldi R18,15
ldi R19,0
ldi R16,241
ldi R17,0
xcall _SdCmd
.dbline 113
xcall _LCD_ChkBusy
.dbline 114
; SdCmd(0x20,0x27); LCD_ChkBusy(); //Active Window Right Reg
ldi R18,39
ldi R19,0
ldi R16,32
ldi R17,0
xcall _SdCmd
.dbline 114
xcall _LCD_ChkBusy
.dbline 115
; SdCmd(0x30,0xef); LCD_ChkBusy(); //Active Window Bottom Reg(240 duty)
ldi R18,239
ldi R19,0
ldi R16,48
ldi R17,0
xcall _SdCmd
.dbline 115
xcall _LCD_ChkBusy
.dbline 116
; SdCmd(0x40,0x00); LCD_ChkBusy(); //Active Window Left Reg
clr R18
clr R19
ldi R16,64
ldi R17,0
xcall _SdCmd
.dbline 116
xcall _LCD_ChkBusy
.dbline 117
; SdCmd(0x50,0x00); LCD_ChkBusy(); //Active Window Top Reg
clr R18
clr R19
ldi R16,80
ldi R17,0
xcall _SdCmd
.dbline 117
xcall _LCD_ChkBusy
.dbline 118
; SdCmd(0x21,0x27); LCD_ChkBusy(); //Display Window Right Reg
ldi R18,39
ldi R19,0
ldi R16,33
ldi R17,0
xcall _SdCmd
.dbline 118
xcall _LCD_ChkBusy
.dbline 119
; SdCmd(0x30,0xef); LCD_ChkBusy(); // Display Window Bottom Reg(240 duty)
ldi R18,239
ldi R19,0
ldi R16,48
ldi R17,0
xcall _SdCmd
.dbline 119
xcall _LCD_ChkBusy
.dbline 120
; SdCmd(0x41,0x00); LCD_ChkBusy(); //Display Window Left Reg
clr R18
clr R19
ldi R16,65
ldi R17,0
xcall _SdCmd
.dbline 120
xcall _LCD_ChkBusy
.dbline 121
; SdCmd(0x51,0x00); LCD_ChkBusy(); // Display Window Top Reg
clr R18
clr R19
ldi R16,81
ldi R17,0
xcall _SdCmd
.dbline 121
xcall _LCD_ChkBusy
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbend
.dbfunc e SdCmd _SdCmd fV
; Com_Data -> R18
; Command -> R16
.even
_SdCmd::
.dbline -1
.dbline 126
; }
; //====================================
; //-----------------------------------
; void SdCmd(uchar Command,uchar Com_Data) //send command
; {
.dbline 127
; SetWR;
sbi 0x12,7
.dbline 127
.dbline 128
; SetRD;
sbi 0x12,5
.dbline 128
.dbline 129
; ClrRS; //RS = 0 输入命令
in R24,0x3
andi R24,254
out 0x3,R24
.dbline 129
.dbline 130
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 130
.dbline 131
; PORTF = Command;
sts 98,R16
.dbline 132
; asm(" nop ");
nop
.dbline 133
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 133
.dbline 134
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 135
; asm(" nop ");
nop
.dbline 136
; SetWR;
sbi 0x12,7
.dbline 136
.dbline 137
; SetCS;
sbi 0x12,6
.dbline 137
.dbline 139
; //====================================
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 140
; asm(" nop ");
nop
.dbline 141
; SetWR;
sbi 0x12,7
.dbline 141
.dbline 142
; SetRD;
sbi 0x12,5
.dbline 142
.dbline 143
; ClrRS; //RS = 0 输入命令
in R24,0x3
andi R24,254
out 0x3,R24
.dbline 143
.dbline 144
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 144
.dbline 145
; PORTF = Com_Data;
sts 98,R18
.dbline 146
; asm(" nop ");
nop
.dbline 147
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 147
.dbline 148
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 149
; asm(" nop ");
nop
.dbline 150
; SetWR;
sbi 0x12,7
.dbline 150
.dbline 151
; SetCS;
sbi 0x12,6
.dbline 151
.dbline -2
L8:
.dbline 0 ; func end
ret
.dbsym r Com_Data 18 c
.dbsym r Command 16 c
.dbend
.dbfunc e SdData _SdData fV
; DData -> R16
.even
_SdData::
.dbline -1
.dbline 155
; }
; //===============================================
; void SdData(uchar DData) //send display data
; {
.dbline 156
; SetWR;
sbi 0x12,7
.dbline 156
.dbline 157
; SetRD;
sbi 0x12,5
.dbline 157
.dbline 158
; SetRS; //RS = 1 输入数据
sbi 0x3,0
.dbline 158
.dbline 159
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 159
.dbline 160
; PORTF = DData;
sts 98,R16
.dbline 161
; asm(" nop ");
nop
.dbline 162
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 162
.dbline 163
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 164
; asm(" nop ");
nop
.dbline 165
; SetWR;
sbi 0x12,7
.dbline 165
.dbline 166
; SetCS;
sbi 0x12,6
.dbline 166
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbsym r DData 16 c
.dbend
.dbfunc e LCD_ChkBusy _LCD_ChkBusy fV
; TempM -> R16
.even
_LCD_ChkBusy::
.dbline -1
.dbline 171
; }
; //====================================
; //=================================
; void LCD_ChkBusy(void)
; {
.dbline 172
; uchar TempM = 0x08;
ldi R16,8
.dbline 173
; DDRG = 0X00; //将端口设为输入
clr R2
sts 100,R2
xjmp L12
L11:
.dbline 175
.dbline 176
lds R16,99
.dbline 177
andi R16,8
.dbline 178
L12:
.dbline 174
; while(TempM)
tst R16
brne L11
.dbline 179
; {
; TempM = PING;
; TempM &= 0x08; //读取DB.3位
; }
; DDRG = 0XFF; //将端口设为输出
ldi R24,255
sts 100,R24
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbsym r TempM 16 c
.dbend
.dbfunc e Welcome_interface _Welcome_interface fV
.even
_Welcome_interface::
sbiw R28,2
.dbline -1
.dbline 183
; }
; //====================================
; void Welcome_interface(void)
; {
.dbline 184
; SdCmd(0x12,0x95);LCD_ChkBusy(); //操作图层1
ldi R18,149
ldi R16,18
xcall _SdCmd
.dbline 184
xcall _LCD_ChkBusy
.dbline 185
; CleanScreen();
xcall _CleanScreen
.dbline 186
; SdCmd(0xf1,0x1f);LCD_ChkBusy(); //设置字型大小
ldi R18,31
ldi R16,241
xcall _SdCmd
.dbline 186
xcall _LCD_ChkBusy
.dbline 189
; //SdCmd(0x60,0x0a);LCD_ChkBusy(); //设置光标X坐标
; //SdCmd(0x70,0x4b);LCD_ChkBusy(); //设置光标Y坐标
; ShowText(10,75,"金特维");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -