📄 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\flashTest\ledtest.c
.dbsym e I_Timer _I_Timer I
_Field::
.blkb 2
.area idata
.word 512
.area data(ram, con, rel)
.dbfile E:\ICC128\2008控制台\2008console0TEST\flashTest\ledtest.c
.dbsym e Field _Field I
.area text(rom, con, rel)
.dbfile E:\ICC128\2008控制台\2008console0TEST\flashTest\ledtest.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 15
;
; //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;
; int Field = 512;
; uint xx[512];
; //#define portout (*(volatile unsigned char*)0x1100)
;
; void port_init(void)
; {
.dbline 16
; PORTA = 0XFF;
ldi R24,255
out 0x1b,R24
.dbline 17
; DDRA = 0XFF;
out 0x1a,R24
.dbline 18
; PORTF = 0XFF;
sts 98,R24
.dbline 19
; DDRF = 0XFF;
sts 97,R24
.dbline 20
; PORTB = 0xFF;
out 0x18,R24
.dbline 21
; DDRB = 0xF7;
ldi R24,247
out 0x17,R24
.dbline 22
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 23
; DDRD = 0xFF;
out 0x11,R24
.dbline 24
; PORTE = 0xFF;
out 0x3,R24
.dbline 25
; DDRE = 0xFF;
out 0x2,R24
.dbline 26
; PORTG = 0XFF;
sts 101,R24
.dbline 27
; 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 35
; }
;
; //TIMER0 initialize - prescale:1024
; // WGM: Normal
; // desired value: 20mSec
; // actual value: 19.968mSec (0.2%)
; void timer0_init(void)
; {
.dbline 36
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 37
; ASSR = 0x00; //set async mode
out 0x30,R2
.dbline 38
; TCNT0 = 0x64; //set count
ldi R24,100
out 0x32,R24
.dbline 39
; OCR0 = 0x9C;
ldi R24,156
out 0x31,R24
.dbline 40
; 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\flashTest\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 45
; }
;
; #pragma interrupt_handler timer0_ovf_isr:17
; void timer0_ovf_isr(void)
; {
.dbline 46
; I_Timer++;
lds R24,_I_Timer
lds R25,_I_Timer+1
adiw R24,1
sts _I_Timer+1,R25
sts _I_Timer,R24
.dbline 47
; if(I_Timer == 50)
cpi R24,50
ldi R30,0
cpc R25,R30
brne L4
.dbline 48
; {
.dbline 49
; PORTG ^= 0x10;
ldi R24,16
lds R2,101
eor R2,R24
sts 101,R2
.dbline 50
; I_Timer =0;
clr R2
clr R3
sts _I_Timer+1,R3
sts _I_Timer,R2
.dbline 51
; }
L4:
.dbline 52
; 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 57
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 59
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 60
; XDIV = 0x00; //xtal divider
clr R2
out 0x3c,R2
.dbline 61
; XMCRA = 0x00; //external memory
sts 109,R2
.dbline 62
; port_init();
xcall _port_init
.dbline 63
; timer0_init();
xcall _timer0_init
.dbline 64
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 65
; EICRA = 0x00; //extended ext ints
sts 106,R2
.dbline 66
; EICRB = 0x00; //extended ext ints
out 0x3a,R2
.dbline 67
; EIMSK = 0x00;
out 0x39,R2
.dbline 68
; TIMSK = 0x01; //timer interrupt sources
ldi R24,1
out 0x37,R24
.dbline 69
; ETIMSK = 0x00; //extended timer interrupt sources
sts 125,R2
.dbline 70
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
; readXDIV -> <dead>
; j -> R22,R23
; i -> R20,R21
.even
_main::
sbiw R28,4
.dbline -1
.dbline 74
; //all peripherals are now initialized
; }
; void main()
; {
.dbline 78
; int i,j;
; unsigned char readXDIV;
;
; init_devices();
xcall _init_devices
.dbline 82
;
;
;
; initLCDM(); //初始化LCD
xcall _initLCDM
.dbline 83
; Welcome_interface(); //显示欢迎界面
xcall _Welcome_interface
.dbline 85
;
; SdCmd(0x10,0x29); LCD_ChkBusy();
ldi R18,41
ldi R19,0
ldi R16,16
ldi R17,0
xcall _SdCmd
.dbline 85
xcall _LCD_ChkBusy
.dbline 86
; SdCmd(0xf1,0x0f);LCD_ChkBusy(); //设置字型大小
ldi R18,15
ldi R19,0
ldi R16,241
ldi R17,0
xcall _SdCmd
.dbline 86
xcall _LCD_ChkBusy
.dbline 87
; ShowText(6,2,"测试 Flash AT45DB161D 读写");
ldi R24,<L8
ldi R25,>L8
std y+1,R25
std y+0,R24
ldi R18,2
ldi R19,0
ldi R16,6
ldi R17,0
xcall _ShowText
.dbline 88
; for ( i=1; i<=48;i++)
ldi R20,1
ldi R21,0
L9:
.dbline 89
.dbline 90
lds R24,101
andi R24,4
sts 101,R24
.dbline 91
ldi R24,1
lds R2,101
eor R2,R24
sts 101,R2
.dbline 92
ldi R24,2
lds R2,101
eor R2,R24
sts 101,R2
.dbline 93
L10:
.dbline 88
subi R20,255 ; offset = 1
sbci R21,255
.dbline 88
ldi R24,48
ldi R25,0
cp R24,R20
cpc R25,R21
brge L9
.dbline 96
; {
; PORTG &= 0x04;
; PORTG ^= 0X01;
; PORTG ^= 0x02;
; }
; //=============================
;
; df_init(); //端口初始化
xcall _df_init
.dbline 97
; j=0;
clr R22
clr R23
.dbline 119
; /*kl:
; for(i=0;i<512;i++)
; xx[i]=3; //初始化
;
; //测试写
; df_write_open(4099*Field);
; //for(i=0;i<5;i++)
; // {
; df_write(xx,512);
; // }
; df_write_close();
; j++;
;
; if(j<10)
; {
; goto kl;
; }
;
; */
; // Write_page(2049,0,xx,512); //读页 一 页地址, 二页内地址, 三 数组存放取出来的数, 四 取多少个字节
; //=============================================
; df_read_open(4099*Field);
lds R18,_Field
lds R19,_Field+1
ldi R16,4099
ldi R17,16
xcall empy16s
xcall _df_read_open
.dbline 122
; // for(j=0;j<5;j++)
; // {
; df_read(xx,512);
ldi R18,512
ldi R19,2
ldi R16,<_xx
ldi R17,>_xx
xcall _df_read
.dbline 129
; // }
; // df_read_close();
; // Page_Scrape(2049); //页擦除
; // Read_Page(2049,0,xx,512); //读页 一 页地址, 二页内地址, 三 数组存放取出来的数, 四 取多少个字节
; // df_read(1,1,xx,128);
;
; ShowNumber(0,0,512,xx);
ldi R24,<_xx
ldi R25,>_xx
std y+3,R25
std y+2,R24
ldi R24,512
ldi R25,2
std y+1,R25
std y+0,R24
clr R18
clr R19
clr R16
clr R17
xcall _ShowNumber
L13:
.dbline 133
.dbline 134
.dbline 135
L14:
.dbline 132
xjmp L13
X0:
.dbline -2
L7:
adiw R28,4
.dbline 0 ; func end
ret
.dbsym l readXDIV 5 c
.dbsym r j 22 I
.dbsym r i 20 I
.dbend
.dbfunc e initLCDM _initLCDM fV
.even
_initLCDM::
.dbline -1
.dbline 139
;
; //=========================
; while(1)
; {
; ;// portout = 0xaa;
; }
; }
; //============================
; void initLCDM(void)
; {
.dbline 140
; PORTF |= 0XFF;
lds R24,98
ori R24,255
sts 98,R24
.dbline 141
; SetCS;
sbi 0x12,6
.dbline 141
.dbline 142
; SetRD;
sbi 0x12,5
.dbline 142
.dbline 143
; SetWR;
sbi 0x12,7
.dbline 143
.dbline 144
; SetRS;
sbi 0x3,0
.dbline 144
.dbline 151
; // 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 151
xcall _LCD_ChkBusy
.dbline 152
; SdCmd(0x81,0x40); LCD_ChkBusy(); //by default
ldi R18,64
ldi R19,0
ldi R16,129
ldi R17,0
xcall _SdCmd
.dbline 152
xcall _LCD_ChkBusy
.dbline 153
; 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 153
xcall _LCD_ChkBusy
.dbline 154
; 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 154
xcall _LCD_ChkBusy
.dbline 155
; 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 155
xcall _LCD_ChkBusy
.dbline 156
; 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 156
xcall _LCD_ChkBusy
.dbline 157
; 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 157
xcall _LCD_ChkBusy
.dbline 158
; SdCmd(0xf1,0x0f); LCD_ChkBusy(); //设置字型大小
ldi R18,15
ldi R19,0
ldi R16,241
ldi R17,0
xcall _SdCmd
.dbline 158
xcall _LCD_ChkBusy
.dbline 159
; SdCmd(0x20,0x27); LCD_ChkBusy(); //Active Window Right Reg
ldi R18,39
ldi R19,0
ldi R16,32
ldi R17,0
xcall _SdCmd
.dbline 159
xcall _LCD_ChkBusy
.dbline 160
; SdCmd(0xf0,0xa0); LCD_ChkBusy(); //Font Control Reg
ldi R18,160
ldi R19,0
ldi R16,240
ldi R17,0
xcall _SdCmd
.dbline 160
xcall _LCD_ChkBusy
.dbline 161
; 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 161
xcall _LCD_ChkBusy
.dbline 162
; SdCmd(0x40,0x00); LCD_ChkBusy(); //Active Window Left Reg
clr R18
clr R19
ldi R16,64
ldi R17,0
xcall _SdCmd
.dbline 162
xcall _LCD_ChkBusy
.dbline 163
; SdCmd(0x50,0x00); LCD_ChkBusy(); //Active Window Top Reg
clr R18
clr R19
ldi R16,80
ldi R17,0
xcall _SdCmd
.dbline 163
xcall _LCD_ChkBusy
.dbline 164
; SdCmd(0x21,0x27); LCD_ChkBusy(); //Display Window Right Reg
ldi R18,39
ldi R19,0
ldi R16,33
ldi R17,0
xcall _SdCmd
.dbline 164
xcall _LCD_ChkBusy
.dbline 165
; 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 165
xcall _LCD_ChkBusy
.dbline 166
; SdCmd(0x41,0x00); LCD_ChkBusy(); //Display Window Left Reg
clr R18
clr R19
ldi R16,65
ldi R17,0
xcall _SdCmd
.dbline 166
xcall _LCD_ChkBusy
.dbline 167
; SdCmd(0x51,0x00); LCD_ChkBusy(); // Display Window Top Reg
clr R18
clr R19
ldi R16,81
ldi R17,0
xcall _SdCmd
.dbline 167
xcall _LCD_ChkBusy
.dbline -2
L16:
.dbline 0 ; func end
ret
.dbend
.dbfunc e SdCmd _SdCmd fV
; Com_Data -> R18
; Command -> R16
.even
_SdCmd::
.dbline -1
.dbline 172
; }
; //====================================
; //-----------------------------------
; void SdCmd(uchar Command,uchar Com_Data) //send command
; {
.dbline 173
; SetWR;
sbi 0x12,7
.dbline 173
.dbline 174
; SetRD;
sbi 0x12,5
.dbline 174
.dbline 175
; ClrRS; //RS = 0 输入命令
in R24,0x3
andi R24,254
out 0x3,R24
.dbline 175
.dbline 176
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 176
.dbline 177
; PORTF = Command;
sts 98,R16
.dbline 178
; asm(" nop ");
nop
.dbline 179
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 179
.dbline 180
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 181
; asm(" nop ");
nop
.dbline 182
; SetWR;
sbi 0x12,7
.dbline 182
.dbline 183
; SetCS;
sbi 0x12,6
.dbline 183
.dbline 185
; //====================================
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 186
; asm(" nop ");
nop
.dbline 187
; SetWR;
sbi 0x12,7
.dbline 187
.dbline 188
; SetRD;
sbi 0x12,5
.dbline 188
.dbline 189
; ClrRS; //RS = 0 输入命令
in R24,0x3
andi R24,254
out 0x3,R24
.dbline 189
.dbline 190
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 190
.dbline 191
; PORTF = Com_Data;
sts 98,R18
.dbline 192
; asm(" nop ");
nop
.dbline 193
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 193
.dbline 194
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 195
; asm(" nop ");
nop
.dbline 196
; SetWR;
sbi 0x12,7
.dbline 196
.dbline 197
; SetCS;
sbi 0x12,6
.dbline 197
.dbline -2
L17:
.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 201
; }
; //===============================================
; void SdData(uchar DData) //send display data
; {
.dbline 202
; SetWR;
sbi 0x12,7
.dbline 202
.dbline 203
; SetRD;
sbi 0x12,5
.dbline 203
.dbline 204
; SetRS; //RS = 1 输入数据
sbi 0x3,0
.dbline 204
.dbline 205
; ClrCS;
in R24,0x12
andi R24,191
out 0x12,R24
.dbline 205
.dbline 206
; PORTF = DData;
sts 98,R16
.dbline 207
; asm(" nop ");
nop
.dbline 208
; ClrWR; //写使能
in R24,0x12
andi R24,127
out 0x12,R24
.dbline 208
.dbline 209
; asm(" nop "); // 8MHZ 执行一条指令大约125ns
nop
.dbline 210
; asm(" nop ");
nop
.dbline 211
; SetWR;
sbi 0x12,7
.dbline 211
.dbline 212
; SetCS;
sbi 0x12,6
.dbline 212
.dbline -2
L18:
.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 217
; }
; //====================================
; //=================================
; void LCD_ChkBusy(void)
; {
.dbline 218
; uchar TempM = 0x08;
ldi R16,8
.dbline 219
; DDRG = 0X00; //将端口设为输入
clr R2
sts 100,R2
xjmp L21
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -