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

📄 stk500i.lst

📁 文档里面的代码是可以正常使用的
💻 LST
📖 第 1 页 / 共 5 页
字号:
__text_start:
__start:
    001F EFCF      LDI	R28,0xFF
    0020 E0D4      LDI	R29,4
    0021 BFCD      OUT	0x3D,R28
    0022 BFDE      OUT	0x3E,R29
    0023 51C0      SUBI	R28,0x10
    0024 40D0      SBCI	R29,0
    0025 EA0A      LDI	R16,0xAA
    0026 8308      STD	Y+0,R16
    0027 2400      CLR	R0
    0028 E0EA      LDI	R30,0xA
    0029 E0F1      LDI	R31,1
    002A E012      LDI	R17,2
    002B 34E0      CPI	R30,0x40
    002C 07F1      CPC	R31,R17
    002D F011      BEQ	0x0030
    002E 9201      ST	R0,Z+
    002F CFFB      RJMP	0x002B
    0030 8300      STD	Z+0,R16
    0031 E3E4      LDI	R30,0x34
    0032 E0F0      LDI	R31,0
    0033 E0A0      LDI	R26,0
    0034 E0B1      LDI	R27,1
    0035 E010      LDI	R17,0
    0036 33EE      CPI	R30,0x3E
    0037 07F1      CPC	R31,R17
    0038 F021      BEQ	0x003D
    0039 95C8      LPM
    003A 9631      ADIW	R30,1
    003B 920D      ST	R0,X+
    003C CFF9      RJMP	0x0036
    003D D069      RCALL	_main
_exit:
    003E CFFF      RJMP	_exit
_T1_OCR1A:
    003F 938A      ST	R24,-Y
    0040 B78F      IN	R24,0x3F
    0041 938A      ST	R24,-Y
FILE: E:\ICCAVR\icc\stk500\avrasp\tools.c
(0001) 
(0002) #include "stk500.h"
(0003) 
(0004) static unsigned char t1_tick;
(0005) 
(0006) //Konstanten im EEPROM
(0007) //#define EEPROM  __attribute__ ((section (".eeprom")))
(0008) 
(0009) //Variablen im EEPROM
(0010) //EEPROM unsigned char eeprom_sck_period=10;
(0011) unsigned char eeprom_sck_period=10;
(0012) 
(0013) #pragma interrupt_handler T1_OCR1A: 12
(0014) void T1_OCR1A(void) {
(0015) 	t1_tick=1;
    0042 E081      LDI	R24,1
    0043 9380010A  STS	t1_tick,R24
    0045 9189      LD	R24,Y+
    0046 BF8F      OUT	0x3F,R24
    0047 9189      LD	R24,Y+
    0048 9518      RETI
(0016) }
(0017) 
(0018) unsigned char get_t1_tick(void) {
(0019) 	if(t1_tick) {
_get_t1_tick:
    0049 9020010A  LDS	R2,t1_tick
    004B 2022      TST	R2
    004C F029      BEQ	0x0052
(0020) 		t1_tick=0;
    004D 2422      CLR	R2
    004E 9220010A  STS	t1_tick,R2
(0021) 		return 1;
    0050 E001      LDI	R16,1
    0051 C001      RJMP	0x0053
(0022) 		}
(0023) 	return 0;
    0052 2700      CLR	R16
    0053 9508      RET
_wait_ms:
  n                    --> R20
    0054 D9F7      RCALL	push_gset1
    0055 01A8      MOVW	R20,R16
(0024) }
(0025) 
(0026) void wait_ms(unsigned int n) {
    0056 C005      RJMP	0x005C
(0027) 	while(n) {
(0028) 		if(get_t1_tick()) n--;
    0057 DFF1      RCALL	_get_t1_tick
    0058 2300      TST	R16
    0059 F011      BEQ	0x005C
    005A 5041      SUBI	R20,1
    005B 4050      SBCI	R21,0
    005C 3040      CPI	R20,0
    005D 0745      CPC	R20,R21
    005E F7C1      BNE	0x0057
    005F D9EF      RCALL	pop_gset1
    0060 9508      RET
FILE: E:\ICCAVR\icc\stk500\avrasp\interface.c
(0001) /**	\file 
(0002) 	<b>USB receive and transmit</b><br>
(0003) 	Autor: Matthias Wei遝r<br>
(0004) 	Copyright 2005: Matthias Wei遝r<br>
(0005) 	License: QPL (see license.txt)
(0006) 	<hr>
(0007) */
(0008) #include "stk500.h"
(0009) 
(0010) unsigned char checksum;
(0011) 
(0012) //#ifdef CONFIG_INTERFACE_USB
(0013) #if 0
(0014) 
(0015) 	//Hardware
(0016) 	#define	USB_TXE		(PINB&BIT6_POS)
(0017) 	#define	USB_RXF		(PINC&BIT3_POS)
(0018) 	#define	USB_RD_ON	PORTC&=BIT1_NEG
(0019) 	#define	USB_RD_OFF	PORTC|=BIT1_POS
(0020) 	#define	USB_WR_ON	PORTC|=BIT2_POS
(0021) 	#define	USB_WR_OFF	PORTC&=BIT2_NEG
(0022) 	
(0023) 	/**
(0024) 		Initializes the usb interface
(0025) 	*/
(0026) 	void interface_init(void)
(0027) 	{
(0028) 		PORTC |= BIT1_POS;			//USB_RD inactive
(0029) 		DDRC |= BIT1_POS|BIT2_POS;	//USB_RD, USB_WR as output
(0030) 	}
(0031) 	
(0032) 	/**
(0033) 		Reads a byte from the USB interface
(0034) 		
(0035) 		@return received character or -1 if no character has been received
(0036) 	*/
(0037) 	signed int interface_getc(void)
(0038) 	{
(0039) 		unsigned char t;
(0040) 		
(0041) 		if(!USB_RXF)
(0042) 		{	
(0043) 			USB_RD_ON;
(0044) 			asm("NOP");
(0045) 			t = PIND;
(0046) 			USB_RD_OFF;
(0047) 			
(0048) 			return t;
(0049) 		}
(0050) 		else return -1;
(0051) 	}
(0052) 	
(0053) 	/**
(0054) 		Writes a byte to the USB
(0055) 		
(0056) 		@param t Byte to be written	
(0057) 	*/
(0058) 	void interface_putc(unsigned char t)
(0059) 	{
(0060) 		while(USB_TXE);
(0061) 		
(0062) 		//PORTD auf Ausgang
(0063) 		DDRD = 0xFF;
(0064) 		//Daten auf den Port
(0065) 		PORTD = t;
(0066) 		
(0067) 		USB_WR_ON;
(0068) 		USB_WR_OFF;
(0069) 		
(0070) 		//PORTC auf Eingang
(0071) 		DDRD = 0x00;
(0072) 		//Pull-Ups ein
(0073) 		PORTD = 0xFF;
(0074) 		
(0075) 		checksum ^= t;
(0076) 	}
(0077) 	
(0078) #endif
(0079) 
(0080) #ifdef CONFIG_INTERFACE_RS232
(0081) 	
(0082) /**
(0083) 	Initializes the rs232 interface
(0084) 	3.6864MHz
(0085) 	Autor: Lukas Salzburger
(0086) */
(0087) void interface_init(void) {
(0088) 	UCSR0B =  (1<<RXEN0) | (1<<TXEN0);
_interface_init:
    0061 E188      LDI	R24,0x18
    0062 938000C1  STS	0xC1,R24
(0089) 	UBRR0L = 1;
    0064 E081      LDI	R24,1
    0065 938000C4  STS	0xC4,R24
(0090) 	UBRR0H = 0;
    0067 2422      CLR	R2
    0068 922000C5  STS	0xC5,R2
    006A 9508      RET
(0091) }
(0092) 
(0093) /**
(0094) 	Reads a byte from the UART interface
(0095) 	
(0096) 	Autor: Lukas Salzburger
(0097) 	
(0098) 	@return received character or -1 if no character has been received
(0099) */
(0100) signed int interface_getc(void) {	/*获取PC机发来的一字节信息*/
(0101) 	
(0102) 	if (UCSR0A & (1<<RXC0)) {
_interface_getc:
    006B 902000C0  LDS	R2,0xC0
    006D FE27      SBRS	R2,7
    006E C004      RJMP	0x0073
(0103) 		return UDR0;
    006F 910000C6  LDS	R16,0xC6
    0071 2711      CLR	R17
    0072 C002      RJMP	0x0075
(0104) 		}
(0105) 	else {
(0106) 		return -1;
    0073 EF0F      LDI	R16,0xFF
    0074 EF1F      LDI	R17,0xFF
    0075 9508      RET
(0107) 		}
(0108) }
(0109) 
(0110) /**
(0111) 	Writes a byte to the UART
(0112) 	
(0113) 	Autor: Lukas Salzburger
(0114) 	
(0115) 	@param t Byte to be written	
(0116) */
(0117) void interface_putc(unsigned char t) {
(0118) 
(0119) 	while (!(UCSR0A & (1<<UDRE0)));
_interface_putc:
  t                    --> R16
    0076 902000C0  LDS	R2,0xC0
    0078 FE25      SBRS	R2,5
    0079 CFFC      RJMP	_interface_putc
(0120) 	
(0121) 	UDR0 = t;
    007A 930000C6  STS	0xC6,R16
(0122) 	checksum ^= t;
    007C 9020010B  LDS	R2,checksum
    007E 2620      EOR	R2,R16
    007F 9220010B  STS	checksum,R2
    0081 9508      RET
_interface_print:
  s                    --> R20
    0082 D9C9      RCALL	push_gset1
    0083 01A8      MOVW	R20,R16
(0123) }
(0124) 
(0125) #endif
(0126) 	
(0127) /**
(0128) 	Writes a string to USB
(0129) 	
(0130) 	@param s The string to be send
(0131) */
(0132) void interface_print(unsigned char *s)
(0133) {
    0084 C005      RJMP	0x008A
(0134) 	while(*s)
(0135) 	{
(0136) 		interface_putc(*s);
    0085 01FA      MOVW	R30,R20
    0086 8100      LDD	R16,Z+0
    0087 DFEE      RCALL	_interface_putc
(0137) 		s++;
    0088 5F4F      SUBI	R20,0xFF
    0089 4F5F      SBCI	R21,0xFF
    008A 01FA      MOVW	R30,R20
    008B 8020      LDD	R2,Z+0
    008C 2022      TST	R2
    008D F7B9      BNE	0x0085
    008E D9C0      RCALL	pop_gset1
    008F 9508      RET
_interface_put16:
  t                    --> R20
    0090 D9BB      RCALL	push_gset1
    0091 01A8      MOVW	R20,R16
(0138) 	}
(0139) }
(0140) 
(0141) /**
(0142) 	Sends a 16 bit value over the USB
(0143) 	MSB first
(0144) 	
(0145) 	@param t Value to be send
(0146) */
(0147) void interface_put16(unsigned int t)
(0148) {
(0149) 	interface_putc((t>>8)&0xFF);
    0092 018A      MOVW	R16,R20
    0093 2F01      MOV	R16,R17
    0094 2711      CLR	R17
    0095 7010      ANDI	R17,0
    0096 DFDF      RCALL	_interface_putc
(0150) 	interface_putc((t>>0)&0xFF);
    0097 2F04      MOV	R16,R20
    0098 7010      ANDI	R17,0
    0099 DFDC      RCALL	_interface_putc
    009A D9B4      RCALL	pop_gset1
    009B 9508      RET
(0151) }
(0152) 
(0153) /**
(0154) 	Resets the checksum accumulator
(0155) */
(0156) void interface_reset_check(void)
(0157) {
(0158) 	checksum=0;
_interface_reset_check:
    009C 2422      CLR	R2
    009D 9220010B  STS	checksum,R2
    009F 9508      RET
(0159) }
(0160) 
(0161) /**
(0162) 	Sends the accumulated checksum
(0163) */
(0164) void interface_send_check(void)
(0165) {
(0166) 	interface_putc(checksum);
_interface_send_check:
    00A0 9100010B  LDS	R16,checksum
    00A2 DFD3      RCALL	_interface_putc
(0167) 	checksum=0;
    00A3 2422      CLR	R2
    00A4 9220010B  STS	checksum,R2
    00A6 9508      RET
_main:
  i                    --> Y+1
  msg_size             --> R22
  seq_num              --> Y+0
  checksum             --> R12
  t                    --> R20
  state                --> R14
  rec_data             --> R10
    00A7 9723      SBIW	R28,3
FILE: E:\ICCAVR\icc\stk500\avrasp\main.c
(0001) /**	\file
(0002) 	<b>USBisp main</b><br>
(0003) 	Autor: Matthias Wei遝r<br>
(0004) 	Copyright 2005: Matthias Wei遝r<br>
(0005) 	License: QPL (see license.txt)
(0006) 	<hr>
(0007) */
(0008) /*! \mainpage USBisp STK500 v2
(0009) 
(0010) 	(c)2005 by Matthias Weisser
(0011) 
(0012) 	This software is distributed under the QPL
(0013) 	see license.txt for more information
(0014) 
(0015)  	\section Compiler
(0016)  	latest WINAVR
(0017) 
(0018) 	\section version history version history
(0019) 	<b>v1.0</b>
(0020) 	<ul>
(0021) 		<li>First release</li>
(0022) 	</ul>
(0023) */
(0024) #include "stk500.h"
(0025) 
(0026) //States used in the receive state machine
(0027) #define	ST_START		0xF000								/*消息开始0x1B					*/
(0028) #define	ST_GET_SEQ_NUM	0xF001								/*消息包号						*/
(0029) #define ST_MSG_SIZE_1	0xF002								/*消息长度						*/
(0030) #define ST_MSG_SIZE_2	0xF003								/*消息长度						*/
(0031) #define ST_GET_TOKEN	0xF004								/*消息记号0x0E					*/
(0032) #define ST_GET_DATA		0xF005								/*消息数据						*/
(0033) #define	ST_GET_CHECK	0xF006								/*消息校验						*/
(0034) #define	ST_PROCESS		0xF007								/*消息						*/
(0035) 
(0036) void chip_init(void);
(0037) unsigned char adc_get(char n);
(0038) void process_command(unsigned char seq_num);
(0039) 
(0040) //Some global variables
(0041) unsigned char msg_buffer[300];
(0042) unsigned char clock_speed;
(0043) unsigned char reset_polarity;
(0044) unsigned char param_controller_init;
(0045) unsigned char prgmode;
(0046) 
(0047) unsigned long address;
(0048) 
(0049) void main(void) {
(0050) 	
(0051) 	unsigned int i=0;
    00A8 2400      CLR	R0
    00A9 2411      CLR	R1
    00AA 821A      STD	Y+2,R1
    00AB 8209      STD	Y+1,R0
(0052) 
(0053) 	unsigned char seq_num=0;
    00AC 8208      STD	Y+0,R0
(0054) 	unsigned int msg_size=0;
    00AD 2766      CLR	R22
    00AE 2777      CLR	R23
(0055) 	unsigned char checksum=0;
    00AF 24CC      CLR	R12
(0056) 
(0057) 	/// next state
(0058) 	unsigned int state=ST_START;	/*应该是状态标志*/
    00B0 E080      LDI	R24,0
    00B1 EF90      LDI	R25,0xF0
    00B2 017C      MOVW	R14,R24
(0059) 
(0060) 	unsigned char t;
(0061) 	signed int rec_data;
(0062) 
(0063) 	chip_init();
    00B3 D837      RCALL	_chip_init
(0064) 	interface_init();

⌨️ 快捷键说明

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