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

📄 main.ls

📁 STM8全部资料
💻 LS
📖 第 1 页 / 共 4 页
字号:
   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Parser V4.8.32.1 - 30 Mar 2010
   3                     ; Generator V4.3.4 - 23 Mar 2010
2819                     ; 20 void delay_ms(u16 ms)
2819                     ; 21 {
2821                     	switch	.text
2822  0000               _delay_ms:
2824  0000 89            	pushw	x
2825  0001 88            	push	a
2826       00000001      OFST:	set	1
2829  0002 201b          	jra	L5002
2830  0004               L3002:
2831                     ; 25 				for(i=0;i<250;i++)
2833  0004 0f01          	clr	(OFST+0,sp)
2834  0006               L1102:
2837  0006 0c01          	inc	(OFST+0,sp)
2840  0008 7b01          	ld	a,(OFST+0,sp)
2841  000a a1fa          	cp	a,#250
2842  000c 25f8          	jrult	L1102
2843                     ; 27 				for(i=0;i<75;i++)
2845  000e 0f01          	clr	(OFST+0,sp)
2846  0010               L7102:
2849  0010 0c01          	inc	(OFST+0,sp)
2852  0012 7b01          	ld	a,(OFST+0,sp)
2853  0014 a14b          	cp	a,#75
2854  0016 25f8          	jrult	L7102
2855                     ; 29 				ms--;
2857  0018 1e02          	ldw	x,(OFST+1,sp)
2858  001a 1d0001        	subw	x,#1
2859  001d 1f02          	ldw	(OFST+1,sp),x
2860  001f               L5002:
2861                     ; 23 			while(ms!=0)
2863  001f 1e02          	ldw	x,(OFST+1,sp)
2864  0021 26e1          	jrne	L3002
2865                     ; 31 }
2868  0023 5b03          	addw	sp,#3
2869  0025 81            	ret
2908                     ; 33 void delay_us(u16 us)
2908                     ; 34 {
2909                     	switch	.text
2910  0026               _delay_us:
2912  0026 89            	pushw	x
2913  0027 88            	push	a
2914       00000001      OFST:	set	1
2917  0028 201b          	jra	L5402
2918  002a               L3402:
2919                     ; 38 				for(i=0;i<25;i++)
2921  002a 0f01          	clr	(OFST+0,sp)
2922  002c               L1502:
2925  002c 0c01          	inc	(OFST+0,sp)
2928  002e 7b01          	ld	a,(OFST+0,sp)
2929  0030 a119          	cp	a,#25
2930  0032 25f8          	jrult	L1502
2931                     ; 40 				for(i=0;i<7;i++)
2933  0034 0f01          	clr	(OFST+0,sp)
2934  0036               L7502:
2937  0036 0c01          	inc	(OFST+0,sp)
2940  0038 7b01          	ld	a,(OFST+0,sp)
2941  003a a107          	cp	a,#7
2942  003c 25f8          	jrult	L7502
2943                     ; 42 				us--;
2945  003e 1e02          	ldw	x,(OFST+1,sp)
2946  0040 1d0001        	subw	x,#1
2947  0043 1f02          	ldw	(OFST+1,sp),x
2948  0045               L5402:
2949                     ; 36 			while(us!=0)
2951  0045 1e02          	ldw	x,(OFST+1,sp)
2952  0047 26e1          	jrne	L3402
2953                     ; 44 }
2956  0049 5b03          	addw	sp,#3
2957  004b 81            	ret
2999                     ; 17 void SPI_Init(void)
2999                     ; 18 {
3000                     	switch	.text
3001  004c               _SPI_Init:
3005                     ; 19 	SPI_CR1|=0x38;   //波特率
3007  004c c65200        	ld	a,_SPI_CR1
3008  004f aa38          	or	a,#56
3009  0051 c75200        	ld	_SPI_CR1,a
3010                     ; 24 	SPI_CR2|=0x03;   //配置NSS脚为1
3012  0054 c65201        	ld	a,_SPI_CR2
3013  0057 aa03          	or	a,#3
3014  0059 c75201        	ld	_SPI_CR2,a
3015                     ; 25 	SPI_CR1|=0x04;   //配置为主设备
3017  005c 72145200      	bset	_SPI_CR1,#2
3018                     ; 26 	SPI_CR1|=0x40;   //开启SPI
3020  0060 721c5200      	bset	_SPI_CR1,#6
3021                     ; 27 }
3024  0064 81            	ret
3058                     ; 29 void SPI_sendchar(u8 data)
3058                     ; 30 {	
3059                     	switch	.text
3060  0065               _SPI_sendchar:
3064                     ; 31 	SPI_DR=data;
3066  0065 c75204        	ld	_SPI_DR,a
3068  0068               L3212:
3069                     ; 32 	while(!(SPI_SR & 0x02));
3071  0068 c65203        	ld	a,_SPI_SR
3072  006b a502          	bcp	a,#2
3073  006d 27f9          	jreq	L3212
3074                     ; 33 }
3077  006f 81            	ret
3111                     ; 35 u8 SPI_rechar(void)
3111                     ; 36 {	
3112                     	switch	.text
3113  0070               _SPI_rechar:
3115  0070 88            	push	a
3116       00000001      OFST:	set	1
3119                     ; 38 	data=SPI_DR;
3121  0071 c65204        	ld	a,_SPI_DR
3122  0074 6b01          	ld	(OFST+0,sp),a
3124  0076               L7412:
3125                     ; 39 	while(!(SPI_SR & 0x01));
3127  0076 c65203        	ld	a,_SPI_SR
3128  0079 a501          	bcp	a,#1
3129  007b 27f9          	jreq	L7412
3130                     ; 40 	return data;
3132  007d 7b01          	ld	a,(OFST+0,sp)
3135  007f 5b01          	addw	sp,#1
3136  0081 81            	ret
3193                     ; 21 void st7920LcdInit(void)
3193                     ; 22 {
3194                     	switch	.text
3195  0082               _st7920LcdInit:
3197  0082 88            	push	a
3198       00000001      OFST:	set	1
3201                     ; 24 	SPI_Init();
3203  0083 adc7          	call	_SPI_Init
3205                     ; 25 	delay_ms(100);
3207  0085 ae0064        	ldw	x,#100
3208  0088 cd0000        	call	_delay_ms
3210                     ; 26 	PE_DDR|=0x20;
3212  008b 721a5016      	bset	_PE_DDR,#5
3213                     ; 27 	PE_CR1|=0x20;
3215  008f 721a5017      	bset	_PE_CR1,#5
3216                     ; 28 	PE_CR2|=0x20;
3218  0093 721a5018      	bset	_PE_CR2,#5
3219                     ; 29 	sendCodeST7920(0x0c);//整体显示
3221  0097 a60c          	ld	a,#12
3222  0099 ad1d          	call	_sendCodeST7920
3224                     ; 30 	sendCodeST7920(0x01);//清屏
3226  009b a601          	ld	a,#1
3227  009d ad19          	call	_sendCodeST7920
3229                     ; 31 	sendCodeST7920(0x02);
3231  009f a602          	ld	a,#2
3232  00a1 ad15          	call	_sendCodeST7920
3234                     ; 32 	for(i=0;i<64;i++)
3236  00a3 0f01          	clr	(OFST+0,sp)
3237  00a5               L5712:
3238                     ; 33 		lcd_buffer[i]=' ';
3240  00a5 7b01          	ld	a,(OFST+0,sp)
3241  00a7 5f            	clrw	x
3242  00a8 97            	ld	xl,a
3243  00a9 a620          	ld	a,#32
3244  00ab d70005        	ld	(_lcd_buffer,x),a
3245                     ; 32 	for(i=0;i<64;i++)
3247  00ae 0c01          	inc	(OFST+0,sp)
3250  00b0 7b01          	ld	a,(OFST+0,sp)
3251  00b2 a140          	cp	a,#64
3252  00b4 25ef          	jrult	L5712
3253                     ; 35 }
3256  00b6 84            	pop	a
3257  00b7 81            	ret
3292                     ; 37 void sendCodeST7920(u8 Lcd_cmd)
3292                     ; 38 {
3293                     	switch	.text
3294  00b8               _sendCodeST7920:
3296  00b8 88            	push	a
3297       00000000      OFST:	set	0
3300                     ; 39 	E_CLK
3302  00b9 721b5014      	bres	_PE_ODR,#5
3303                     ; 40 	LCD_DELAY()
3306  00bd 9d            nop
3311  00be 9d            nop
3316  00bf 9d            nop
3321  00c0 9d            nop
3326  00c1 9d            nop
3328                     ; 41 	E_SET
3330  00c2 721a5014      	bset	_PE_ODR,#5
3331                     ; 42 	SPI_sendchar(0xF8);
3333  00c6 a6f8          	ld	a,#248
3334  00c8 ad9b          	call	_SPI_sendchar
3336                     ; 43 	SPI_sendchar(Lcd_cmd & 0xF0);
3338  00ca 7b01          	ld	a,(OFST+1,sp)
3339  00cc a4f0          	and	a,#240
3340  00ce ad95          	call	_SPI_sendchar
3342                     ; 44 	SPI_sendchar(Lcd_cmd << 4);
3344  00d0 7b01          	ld	a,(OFST+1,sp)
3345  00d2 97            	ld	xl,a
3346  00d3 a610          	ld	a,#16
3347  00d5 42            	mul	x,a
3348  00d6 9f            	ld	a,xl
3349  00d7 ad8c          	call	_SPI_sendchar
3351                     ; 45 	LCD_DELAY()
3354  00d9 9d            nop
3359  00da 9d            nop
3364  00db 9d            nop
3369  00dc 9d            nop
3374  00dd 9d            nop
3376                     ; 46 	E_CLK
3378  00de 721b5014      	bres	_PE_ODR,#5
3379                     ; 47 	LCD_DELAY()
3382  00e2 9d            nop
3387  00e3 9d            nop
3392  00e4 9d            nop
3397  00e5 9d            nop
3402  00e6 9d            nop
3404                     ; 48 }
3407  00e7 84            	pop	a
3408  00e8 81            	ret
3443                     ; 50 void sendDataST7920(u8 Lcd_data)
3443                     ; 51 {
3444                     	switch	.text
3445  00e9               _sendDataST7920:
3447  00e9 88            	push	a
3448       00000000      OFST:	set	0
3451                     ; 52 	E_CLK
3453  00ea 721b5014      	bres	_PE_ODR,#5
3454                     ; 53 	LCD_DELAY()
3457  00ee 9d            nop
3462  00ef 9d            nop
3467  00f0 9d            nop
3472  00f1 9d            nop
3477  00f2 9d            nop
3479                     ; 54 	E_SET
3481  00f3 721a5014      	bset	_PE_ODR,#5
3482                     ; 55 	SPI_sendchar(0xFA);
3484  00f7 a6fa          	ld	a,#250
3485  00f9 cd0065        	call	_SPI_sendchar
3487                     ; 56 	SPI_sendchar(Lcd_data & 0xF0);
3489  00fc 7b01          	ld	a,(OFST+1,sp)
3490  00fe a4f0          	and	a,#240
3491  0100 cd0065        	call	_SPI_sendchar
3493                     ; 57 	SPI_sendchar(Lcd_data << 4);
3495  0103 7b01          	ld	a,(OFST+1,sp)
3496  0105 97            	ld	xl,a
3497  0106 a610          	ld	a,#16
3498  0108 42            	mul	x,a
3499  0109 9f            	ld	a,xl
3500  010a cd0065        	call	_SPI_sendchar
3502                     ; 58 	LCD_DELAY()
3505  010d 9d            nop
3510  010e 9d            nop
3515  010f 9d            nop
3520  0110 9d            nop
3525  0111 9d            nop
3527                     ; 59 	E_CLK
3529  0112 721b5014      	bres	_PE_ODR,#5
3530                     ; 60 	LCD_DELAY()
3533  0116 9d            nop
3538  0117 9d            nop
3543  0118 9d            nop
3548  0119 9d            nop
3553  011a 9d            nop
3555                     ; 61 }
3558  011b 84            	pop	a
3559  011c 81            	ret
3603                     ; 63 void refreshLCD(const u8 *lcd_stack)
3603                     ; 64 {
3604                     	switch	.text
3605  011d               _refreshLCD:
3607  011d 89            	pushw	x
3608  011e 88            	push	a
3609       00000001      OFST:	set	1
3612                     ; 66 	sendCodeST7920(0x02);	//地址归位
3614  011f a602          	ld	a,#2
3615  0121 ad95          	call	_sendCodeST7920
3617                     ; 67 	for(addr=0;addr<16;addr++)
3619  0123 0f01          	clr	(OFST+0,sp)
3620  0125               L3522:
3621                     ; 69 		sendDataST7920(*(lcd_stack + addr));
3623  0125 7b02          	ld	a,(OFST+1,sp)
3624  0127 97            	ld	xl,a
3625  0128 7b03          	ld	a,(OFST+2,sp)
3626  012a 1b01          	add	a,(OFST+0,sp)
3627  012c 2401          	jrnc	L62
3628  012e 5c            	incw	x
3629  012f               L62:
3630  012f 02            	rlwa	x,a
3631  0130 f6            	ld	a,(x)
3632  0131 adb6          	call	_sendDataST7920
3634                     ; 67 	for(addr=0;addr<16;addr++)
3636  0133 0c01          	inc	(OFST+0,sp)
3639  0135 7b01          	ld	a,(OFST+0,sp)
3640  0137 a110          	cp	a,#16
3641  0139 25ea          	jrult	L3522
3642                     ; 71 	for(addr=32;addr<48;addr++)
3644  013b a620          	ld	a,#32
3645  013d 6b01          	ld	(OFST+0,sp),a

⌨️ 快捷键说明

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