⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stk500i.lst

📁 avr单片机atmage16驱动小灯的一些例程 并且包括一些收发数据的程序利用usb口
💻 LST
📖 第 1 页 / 共 5 页
字号:
(0355) 		prgmode=0;
    02F8 2422      CLR	R2
    02F9 92200070  STS	prgmode,R2
(0356) 
(0357) 		spi_disable();
    02FB D5C9      RCALL	_spi_disable
(0358) 				
(0359) 		LED_RT_OFF;
    02FC EF8D      LDI	R24,0xFD
    02FD EF9F      LDI	R25,0xFF
    02FE B228      IN	R2,0x18
    02FF 2228      AND	R2,R24
    0300 BA28      OUT	0x18,R2
(0360) 		LED_GN_ON;
    0301 9AC0      SBI	0x18,0
(0361) 
(0362) 		num_bytes = 2;
    0302 E082      LDI	R24,2
    0303 E090      LDI	R25,0
    0304 879B      STD	Y+11,R25
    0305 878A      STD	Y+10,R24
(0363) 		msg_buffer[0] = CMD_LEAVE_PROGMODE_ISP;
    0306 E181      LDI	R24,0x11
    0307 93800074  STS	msg_buffer,R24
(0364) 		msg_buffer[1] = STATUS_CMD_OK;		
    0309 2422      CLR	R2
    030A 92200075  STS	msg_buffer+1,R2
(0365) 	}
    030C C55D      RJMP	0x086A
(0366) 	//////////////////////////////////////
(0367) 	//CMD_CHIP_ERASE_ISP
(0368) 	//////////////////////////////////////
(0369) 	else if(cmd==CMD_CHIP_ERASE_ISP)
    030D 858C      LDD	R24,Y+12
    030E 3182      CPI	R24,0x12
    030F F539      BNE	0x0337
(0370) 	{
(0371) 		spi_transfer_8(msg_buffer[3]);
    0310 91000077  LDS	R16,msg_buffer+3
    0312 D5FA      RCALL	_spi_transfer_8
(0372) 		spi_transfer_8(msg_buffer[4]);
    0313 91000078  LDS	R16,0x78
    0315 D5F7      RCALL	_spi_transfer_8
(0373) 		spi_transfer_8(msg_buffer[5]);
    0316 91000079  LDS	R16,0x79
    0318 D5F4      RCALL	_spi_transfer_8
(0374) 		spi_transfer_8(msg_buffer[6]);
    0319 9100007A  LDS	R16,0x7A
    031B D5F1      RCALL	_spi_transfer_8
(0375) 		
(0376) 		//Newer AVR's seems to have a busy bit
(0377) 		//cant test this because I don't have any of these new chips
(0378) 		if(msg_buffer[2]==0)
    031C 90200076  LDS	R2,msg_buffer+2
    031E 2022      TST	R2
    031F F429      BNE	0x0325
(0379) 		{
(0380) 			wait_ms(msg_buffer[1]);
    0320 91000075  LDS	R16,msg_buffer+1
    0322 2711      CLR	R17
    0323 DD38      RCALL	_wait_ms
(0381) 		}
    0324 C007      RJMP	0x032C
(0382) 		else //if(msg_buffer[2]==1)
(0383) 		{
(0384) 			while(spi_transfer_32(0xF0000000)&1);
    0325 E000      LDI	R16,0
    0326 E010      LDI	R17,0
    0327 E020      LDI	R18,0
    0328 EF30      LDI	R19,0xF0
    0329 D5F4      RCALL	_spi_transfer_32
    032A FD00      SBRC	R16,0
    032B CFF9      RJMP	0x0325
(0385) 		}		
(0386) 				
(0387) 		num_bytes = 2;
    032C E082      LDI	R24,2
    032D E090      LDI	R25,0
    032E 879B      STD	Y+11,R25
    032F 878A      STD	Y+10,R24
(0388) 		msg_buffer[0] = CMD_CHIP_ERASE_ISP;
    0330 E182      LDI	R24,0x12
    0331 93800074  STS	msg_buffer,R24
(0389) 		msg_buffer[1] = STATUS_CMD_OK;		
    0333 2422      CLR	R2
    0334 92200075  STS	msg_buffer+1,R2
(0390) 	}
    0336 C533      RJMP	0x086A
(0391) 	//////////////////////////////////////
(0392) 	//CMD_PROGRAM_FLASH_ISP
(0393) 	//////////////////////////////////////
(0394) 	else if(cmd==CMD_PROGRAM_FLASH_ISP)
    0337 858C      LDD	R24,Y+12
    0338 3183      CPI	R24,0x13
    0339 F009      BEQ	0x033B
    033A C1BC      RJMP	0x04F7
(0395) 	{
(0396) 		block_size = ((unsigned int)msg_buffer[1])<<8;
    033B 90A00075  LDS	R10,msg_buffer+1
    033D 24BB      CLR	R11
    033E 2CBA      MOV	R11,R10
    033F 24AA      CLR	R10
(0397) 		block_size |= msg_buffer[2];
    0340 90200076  LDS	R2,msg_buffer+2
    0342 2433      CLR	R3
    0343 28A2      OR	R10,R2
    0344 28B3      OR	R11,R3
(0398) 		mode = msg_buffer[3];
    0345 90E00077  LDS	R14,msg_buffer+3
(0399) 		
(0400) 		//Word Mode
(0401) 		if((mode&1) == 0)
    0347 FCE0      SBRC	R14,0
    0348 C0A2      RJMP	0x03EB
(0402) 		{		
(0403) 			for(i=0;i<block_size;i++)
    0349 24CC      CLR	R12
    034A 24DD      CLR	R13
    034B C09A      RJMP	0x03E6
(0404) 			{	
(0405) 				//If we have an uneven byte programm the
(0406) 				//high byte			
(0407) 				if(i&1)
    034C FEC0      SBRS	R12,0
    034D C005      RJMP	0x0353
(0408) 				{
(0409) 					spi_transfer_8(msg_buffer[5]|(1<<3));
    034E 91000079  LDS	R16,0x79
    0350 6008      ORI	R16,0x8
    0351 D5BB      RCALL	_spi_transfer_8
(0410) 				}
    0352 C003      RJMP	0x0356
(0411) 				else
(0412) 				{
(0413) 					spi_transfer_8(msg_buffer[5]);
    0353 91000079  LDS	R16,0x79
    0355 D5B7      RCALL	_spi_transfer_8
(0414) 				}
(0415) 				
(0416) 				spi_transfer_16(address&0xFFFF);
    0356 EF4F      LDI	R20,0xFF
    0357 EF5F      LDI	R21,0xFF
    0358 E060      LDI	R22,0
    0359 E070      LDI	R23,0
    035A 9040006E  LDS	R4,address+2
    035C 9050006F  LDS	R5,address+3
    035E 9020006C  LDS	R2,address
    0360 9030006D  LDS	R3,address+1
    0362 2224      AND	R2,R20
    0363 2235      AND	R3,R21
    0364 2246      AND	R4,R22
    0365 2257      AND	R5,R23
    0366 0181      MOVW	R16,R2
    0367 D5AA      RCALL	_spi_transfer_16
(0417) 				spi_transfer_8(msg_buffer[i+10]);
    0368 E784      LDI	R24,0x74
    0369 E090      LDI	R25,0
    036A 01F6      MOVW	R30,R12
    036B 963A      ADIW	R30,0xA
    036C 0FE8      ADD	R30,R24
    036D 1FF9      ADC	R31,R25
    036E 8100      LDD	R16,Z+0
    036F D59D      RCALL	_spi_transfer_8
(0418) 				
(0419) 				//Check if we can do polling
(0420) 				if(msg_buffer[8]!=msg_buffer[i+10])
    0370 E784      LDI	R24,0x74
    0371 E090      LDI	R25,0
    0372 01F6      MOVW	R30,R12
    0373 963A      ADIW	R30,0xA
    0374 0FE8      ADD	R30,R24
    0375 1FF9      ADC	R31,R25
    0376 8020      LDD	R2,Z+0
    0377 9030007C  LDS	R3,0x7C
    0379 1432      CP	R3,R2
    037A F0B1      BEQ	0x0391
(0421) 				{
(0422) 					polling_address = address&0xFFFF;
    037B EF4F      LDI	R20,0xFF
    037C EF5F      LDI	R21,0xFF
    037D E060      LDI	R22,0
    037E E070      LDI	R23,0
    037F 9040006E  LDS	R4,address+2
    0381 9050006F  LDS	R5,address+3
    0383 9020006C  LDS	R2,address
    0385 9030006D  LDS	R3,address+1
    0387 2224      AND	R2,R20
    0388 2235      AND	R3,R21
    0389 2246      AND	R4,R22
    038A 2257      AND	R5,R23
    038B 01FE      MOVW	R30,R28
    038C 8222      STD	Z+2,R2
    038D 8233      STD	Z+3,R3
    038E 8244      STD	Z+4,R4
    038F 8255      STD	Z+5,R5
(0423) 				}
    0390 C004      RJMP	0x0395
(0424) 				//If not switch the mode hard waiting
(0425) 				else
(0426) 				{
(0427) 					mode = (mode&(~0x0E)) | 0x02;
    0391 2D8E      MOV	R24,R14
    0392 7F81      ANDI	R24,0xF1
    0393 6082      ORI	R24,2
    0394 2EE8      MOV	R14,R24
(0428) 				}
(0429) 				
(0430) 				//Different polling methods
(0431) 				//Hard waiting
(0432) 				if((mode&0x0E) == 0x02)
    0395 2D8E      MOV	R24,R14
    0396 708E      ANDI	R24,0xE
    0397 3082      CPI	R24,2
    0398 F429      BNE	0x039E
(0433) 				{
(0434) 					wait_ms(msg_buffer[4]);
    0399 91000078  LDS	R16,0x78
    039B 2711      CLR	R17
    039C DCBF      RCALL	_wait_ms
(0435) 				}
    039D C02B      RJMP	0x03C9
(0436) 				//Data polling
(0437) 				else if((mode&0x0E) == 0x04)
    039E 2D8E      MOV	R24,R14
    039F 708E      ANDI	R24,0xE
    03A0 3084      CPI	R24,4
    03A1 F4B9      BNE	0x03B9
(0438) 				{
(0439) 					do{
(0440) 						//If we have an uneven byte read the
(0441) 						//high byte			
(0442) 						if(i&1)
    03A2 FEC0      SBRS	R12,0
    03A3 C005      RJMP	0x03A9
(0443) 						{
(0444) 							spi_transfer_8(msg_buffer[7]|(1<<3));
    03A4 9100007B  LDS	R16,0x7B
    03A6 6008      ORI	R16,0x8
    03A7 D565      RCALL	_spi_transfer_8
(0445) 						}
    03A8 C003      RJMP	0x03AC
(0446) 						else
(0447) 						{
(0448) 							spi_transfer_8(msg_buffer[7]);
    03A9 9100007B  LDS	R16,0x7B
    03AB D561      RCALL	_spi_transfer_8
(0449) 						}
(0450) 						spi_transfer_16(polling_address);
    03AC 01FE      MOVW	R30,R28
    03AD 8102      LDD	R16,Z+2
    03AE 8113      LDD	R17,Z+3
    03AF D562      RCALL	_spi_transfer_16
(0451) 						tmp=spi_transfer_8(0x00);
    03B0 2700      CLR	R16
    03B1 D55B      RCALL	_spi_transfer_8
    03B2 870D      STD	Y+13,R16
(0452) 					}while(tmp==msg_buffer[8]);
    03B3 9020007C  LDS	R2,0x7C
    03B5 840D      LDD	R0,Y+13
    03B6 1402      CP	R0,R2
    03B7 F351      BEQ	0x03A2
(0453) 				}
    03B8 C010      RJMP	0x03C9
(0454) 				//RDY/BSY polling
(0455) 				else if((mode&0x0E) == 0x08)
    03B9 2D8E      MOV	R24,R14
    03BA 708E      ANDI	R24,0xE
    03BB 3088      CPI	R24,0x8
    03BC F441      BNE	0x03C5
(0456) 				{
(0457) 					while(spi_transfer_32(0xF0000000)&1);
    03BD E000      LDI	R16,0
    03BE E010      LDI	R17,0
    03BF E020      LDI	R18,0
    03C0 EF30      LDI	R19,0xF0
    03C1 D55C      RCALL	_spi_transfer_32
    03C2 FD00      SBRC	R16,0
    03C3 CFF9      RJMP	0x03BD
(0458) 				}
    03C4 C004      RJMP	0x03C9
(0459) 				//If something was not correct with the given mode do
(0460) 				//hard waiting. Should never reach this point
(0461) 				else
(0462) 				{
(0463) 					wait_ms(msg_buffer[4]);					
    03C5 91000078  LDS	R16,0x78
    03C7 2711      CLR	R17
    03C8 DC93      RCALL	_wait_ms
(0464) 				}
(0465) 				
(0466) 				//increment (word) address only when we have an uneven (byte) address
(0467) 				if(i&1) address++;
    03C9 FEC0      SBRS	R12,0
    03CA C018      RJMP	0x03E3
    03CB E041      LDI	R20,1
    03CC E050      LDI	R21,0
    03CD E060      LDI	R22,0
    03CE E070      LDI	R23,0
    03CF 9040006E  LDS	R4,address+2
    03D1 9050006F  LDS	R5,address+3
    03D3 9020006C  LDS	R2,address
    03D5 9030006D  LDS	R3,address+1
    03D7 0E24      ADD	R2,R20
    03D8 1E35      ADC	R3,R21
    03D9 1E46      ADC	R4,R22
    03DA 1E57      ADC	R5,R23
    03DB 9230006D  STS	address+1,R3
    03DD 9220006C  STS	address,R2
    03DF 9250006F  STS	address+3,R5
    03E1 9240006E  STS	address+2,R4
    03E3 01C6      MOVW	R24,R12
    03E4 9601      ADIW	R24,1
    03E5 016C      MOVW	R12,R24
    03E6 14CA      CP	R12,R10
    03E7 04DB      CPC	R13,R11
    03E8 F408      BCC	0x03EA
    03E9 CF62      RJMP	0x034C
(0468) 			}			
(0469) 		}
    03EA C101      RJMP	0x04EC
(0470) 		//Page Mode
(0471) 		else
(0472) 		{
(0473) 			for(i=0;i<block_size;i++)
    03EB 24CC      CLR	R12
    03EC 24DD      CLR	R13
    03ED C081      RJMP	0x046F
(0474) 			{
(0475) 				//If we have an uneven byte programm the
(0476) 				//high byte			
(0477) 				if(i&1)
    03EE FEC0      SBRS	R12,0
    03EF C005      RJMP	0x03F5
(0478) 				{
(0479) 					spi_transfer_8(msg_buffer[5]|(1<<3));
    03F0 91000079  LDS	R16,0x79
    03F2 6008      ORI	R16,0x8
    03F3 D519      RCALL	_spi_transfer_8
(0480) 				}
    03F4 C003      RJMP	0x03F8
(0481) 				else
(0482) 				{
(0483) 					spi_transfer_8(msg_buffer[5]);
    03F5 91000079  LDS	R16,0x79
    03F7 D515      RCALL	_spi_transfer_8
(0484) 				}
(0485) 				
(0486) 				spi_transfer_16(address&0xFFFF);
    03F8 EF4F      LDI	R20,0xFF
    03F9 EF5F      LDI	R21,0xFF
    03FA E060      LDI	R22,0
    03FB E070      LDI	R23,0
    03FC 9040006E  LDS	R4,address+2
    03FE 9050006F  LDS	R5,address+3
    0400 9020006C  LDS	R2,address
    0402 9030006D  LDS	R3,address+1
    0404 2224      AND	R2,R20
    0405 2235      AND	R3,R21
    0406 2246      AND	R4,R22
    0407 2257      AND	R5,R23
    0408 0181      MOVW	R16,R2
    0409 D508      RCALL	_spi_transfer_16
(0487) 				spi_transfer_8(msg_buffer[i+10]);
    040A E784      LDI	R24,0x74
    040B E090      LDI	R25,0
    040C 01F6      MOVW	R30,R12
    040D 963A      ADIW	R30,0xA
    040E 0FE8      ADD	R30,R24
    040F 1FF9      ADC	R31,R25
    0410 8100      LDD	R16,Z+0
    0411 D4FB      RCALL	_spi_transfer_8
(0488) 				
(0489) 				//Check if we can do polling
(0490) 				if(msg_buffer[8]!=msg_buffer[i+10])
    0412 E784      LDI	R24,0x74
    0413 E090      LDI	R25,0
    0414 01F6      MOVW	R30,R12
    0415 963A      ADIW	R30,0xA
    0416 0FE8      ADD	R30,R24
    0417 1FF9      ADC	R31,R25
    0418 8020      LDD	R2,Z+0
    0419 9030007C  LDS	R3,0x7C
    041B 1432      CP	R3,R2
    041C F409      BNE	0x041E
    041D C034      RJMP	0x0452
(0491) 				{
(0492) 					//We have to check if we have an uneven byte. 
(0493) 					//Set the polling address to a byte address
(0494) 					//so that we can poll the right location
(0495) 					polling_address = (address&0xFFFF)*2;
    041E EF4F      LDI	R20,0xFF
    041F EF5F      LDI	R21,0xFF
    0420 E060      LDI	R22,0
    0421 E070      LDI	R23,0
    0422 9040006E  LDS	R4,address+2
    0424 9050006F  LDS	R5,address+3
    0426 9020006C  LDS	R2,address
    0428 9030006D  LDS	R3,address+1
    042A 2224      AND	R2,R20
    042B 2235      AND	R3,R21
    042C 2246      AND	R4,R22
    042D 2257      AND	R5,R23
    042E E042      LDI	R20,2
    042F E050      LDI	R21,0
    0430 E060      LDI	R22,0
    0431 E070      LDI	R23,0
    0432 925A      ST	R5,-Y
    0433 924A      ST	R4,-Y
    0434 923A      ST	R3,-Y
    0435 922A      ST	R2,-Y
    0436 018A      MOVW	R16,R20
    0437 019B      MOVW	R18,R22
    0438 D54C      RCALL	empy32s
    0439 01FE      MOVW	R30,R28
    043A 8302      STD	Z+2,R16
    043B 8313      STD	Z+3,R17
    043C 8324      STD	Z+4,R18
    043D 8335      STD	Z+5,R19
(0496) 					if(i&1) polling_address++;
    043E FEC0      SBRS	R12,0
    043F C012      RJMP	0x0452
    0440 E041      LDI	R20,1
    0441 E050      LDI	R21,0
    0442 E060      LDI	R22,0

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -