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

📄 main.ls

📁 STM8全部资料
💻 LS
📖 第 1 页 / 共 3 页
字号:
   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Parser V4.8.32.1 - 30 Mar 2010
   3                     ; Generator V4.3.4 - 23 Mar 2010
2823                     ; 52 void delay_ms(u16 ms)
2823                     ; 53 {
2825                     	switch	.text
2826  0000               _delay_ms:
2828  0000 89            	pushw	x
2829  0001 88            	push	a
2830       00000001      OFST:	set	1
2833  0002 201b          	jra	L1102
2834  0004               L7002:
2835                     ; 57 				for(i=0;i<250;i++)
2837  0004 0f01          	clr	(OFST+0,sp)
2838  0006               L5102:
2841  0006 0c01          	inc	(OFST+0,sp)
2844  0008 7b01          	ld	a,(OFST+0,sp)
2845  000a a1fa          	cp	a,#250
2846  000c 25f8          	jrult	L5102
2847                     ; 59 				for(i=0;i<75;i++)
2849  000e 0f01          	clr	(OFST+0,sp)
2850  0010               L3202:
2853  0010 0c01          	inc	(OFST+0,sp)
2856  0012 7b01          	ld	a,(OFST+0,sp)
2857  0014 a14b          	cp	a,#75
2858  0016 25f8          	jrult	L3202
2859                     ; 61 				ms--;
2861  0018 1e02          	ldw	x,(OFST+1,sp)
2862  001a 1d0001        	subw	x,#1
2863  001d 1f02          	ldw	(OFST+1,sp),x
2864  001f               L1102:
2865                     ; 55 			while(ms!=0)
2867  001f 1e02          	ldw	x,(OFST+1,sp)
2868  0021 26e1          	jrne	L7002
2869                     ; 63 }
2872  0023 5b03          	addw	sp,#3
2873  0025 81            	ret
2916                     ; 65 void delay_us(u16 us)
2916                     ; 66 {
2917                     	switch	.text
2918  0026               _delay_us:
2920  0026 89            	pushw	x
2921  0027 88            	push	a
2922       00000001      OFST:	set	1
2925  0028 201b          	jra	L5502
2926  002a               L3502:
2927                     ; 70 				for(i=0;i<25;i++)
2929  002a 0f01          	clr	(OFST+0,sp)
2930  002c               L1602:
2933  002c 0c01          	inc	(OFST+0,sp)
2936  002e 7b01          	ld	a,(OFST+0,sp)
2937  0030 a119          	cp	a,#25
2938  0032 25f8          	jrult	L1602
2939                     ; 72 				for(i=0;i<7;i++)
2941  0034 0f01          	clr	(OFST+0,sp)
2942  0036               L7602:
2945  0036 0c01          	inc	(OFST+0,sp)
2948  0038 7b01          	ld	a,(OFST+0,sp)
2949  003a a107          	cp	a,#7
2950  003c 25f8          	jrult	L7602
2951                     ; 74 				us--;
2953  003e 1e02          	ldw	x,(OFST+1,sp)
2954  0040 1d0001        	subw	x,#1
2955  0043 1f02          	ldw	(OFST+1,sp),x
2956  0045               L5502:
2957                     ; 68 			while(us!=0)
2959  0045 1e02          	ldw	x,(OFST+1,sp)
2960  0047 26e1          	jrne	L3502
2961                     ; 76 }
2964  0049 5b03          	addw	sp,#3
2965  004b 81            	ret
3007                     ; 17 void SPI_Init(void)
3007                     ; 18 {
3008                     	switch	.text
3009  004c               _SPI_Init:
3013                     ; 19 	SPI_CR1|=0x38;   //波特率
3015  004c c65200        	ld	a,_SPI_CR1
3016  004f aa38          	or	a,#56
3017  0051 c75200        	ld	_SPI_CR1,a
3018                     ; 24 	SPI_CR2|=0x03;   //配置NSS脚为1
3020  0054 c65201        	ld	a,_SPI_CR2
3021  0057 aa03          	or	a,#3
3022  0059 c75201        	ld	_SPI_CR2,a
3023                     ; 25 	SPI_CR1|=0x04;   //配置为主设备
3025  005c 72145200      	bset	_SPI_CR1,#2
3026                     ; 26 	SPI_CR1|=0x40;   //开启SPI
3028  0060 721c5200      	bset	_SPI_CR1,#6
3029                     ; 27 }
3032  0064 81            	ret
3068                     ; 29 void SPI_sendchar(u8 data)
3068                     ; 30 {	
3069                     	switch	.text
3070  0065               _SPI_sendchar:
3074                     ; 31 	SPI_DR=data;
3076  0065 c75204        	ld	_SPI_DR,a
3078  0068               L5312:
3079                     ; 32 	while(!(SPI_SR & 0x02));
3081  0068 c65203        	ld	a,_SPI_SR
3082  006b a502          	bcp	a,#2
3083  006d 27f9          	jreq	L5312
3084                     ; 33 }
3087  006f 81            	ret
3123                     ; 35 u8 SPI_rechar(void)
3123                     ; 36 {	
3124                     	switch	.text
3125  0070               _SPI_rechar:
3127  0070 88            	push	a
3128       00000001      OFST:	set	1
3131                     ; 38 	data=SPI_DR;
3133  0071 c65204        	ld	a,_SPI_DR
3134  0074 6b01          	ld	(OFST+0,sp),a
3136  0076               L3612:
3137                     ; 39 	while(!(SPI_SR & 0x01));
3139  0076 c65203        	ld	a,_SPI_SR
3140  0079 a501          	bcp	a,#1
3141  007b 27f9          	jreq	L3612
3142                     ; 40 	return data;
3144  007d 7b01          	ld	a,(OFST+0,sp)
3147  007f 5b01          	addw	sp,#1
3148  0081 81            	ret
3207                     ; 21 void st7920LcdInit(void)
3207                     ; 22 {
3208                     	switch	.text
3209  0082               _st7920LcdInit:
3211  0082 88            	push	a
3212       00000001      OFST:	set	1
3215                     ; 24 	SPI_Init();
3217  0083 adc7          	call	_SPI_Init
3219                     ; 25 	delay_ms(100);
3221  0085 ae0064        	ldw	x,#100
3222  0088 cd0000        	call	_delay_ms
3224                     ; 26 	PE_DDR|=0x20;
3226  008b 721a5016      	bset	_PE_DDR,#5
3227                     ; 27 	PE_CR1|=0x20;
3229  008f 721a5017      	bset	_PE_CR1,#5
3230                     ; 28 	PE_CR2|=0x20;
3232  0093 721a5018      	bset	_PE_CR2,#5
3233                     ; 29 	sendCodeST7920(0x0c);//整体显示
3235  0097 a60c          	ld	a,#12
3236  0099 ad1c          	call	_sendCodeST7920
3238                     ; 30 	sendCodeST7920(0x01);//清屏
3240  009b a601          	ld	a,#1
3241  009d ad18          	call	_sendCodeST7920
3243                     ; 31 	sendCodeST7920(0x02);
3245  009f a602          	ld	a,#2
3246  00a1 ad14          	call	_sendCodeST7920
3248                     ; 32 	for(i=0;i<64;i++)
3250  00a3 0f01          	clr	(OFST+0,sp)
3251  00a5               L3122:
3252                     ; 33 		lcd_buffer[i]=' ';
3254  00a5 7b01          	ld	a,(OFST+0,sp)
3255  00a7 5f            	clrw	x
3256  00a8 97            	ld	xl,a
3257  00a9 a620          	ld	a,#32
3258  00ab e700          	ld	(_lcd_buffer,x),a
3259                     ; 32 	for(i=0;i<64;i++)
3261  00ad 0c01          	inc	(OFST+0,sp)
3264  00af 7b01          	ld	a,(OFST+0,sp)
3265  00b1 a140          	cp	a,#64
3266  00b3 25f0          	jrult	L3122
3267                     ; 35 }
3270  00b5 84            	pop	a
3271  00b6 81            	ret
3308                     ; 37 void sendCodeST7920(u8 Lcd_cmd)
3308                     ; 38 {
3309                     	switch	.text
3310  00b7               _sendCodeST7920:
3312  00b7 88            	push	a
3313       00000000      OFST:	set	0
3316                     ; 39 	E_CLK
3318  00b8 721b5014      	bres	_PE_ODR,#5
3319                     ; 40 	LCD_DELAY()
3322  00bc 9d            nop
3327  00bd 9d            nop
3332  00be 9d            nop
3337  00bf 9d            nop
3342  00c0 9d            nop
3344                     ; 41 	E_SET
3346  00c1 721a5014      	bset	_PE_ODR,#5
3347                     ; 42 	SPI_sendchar(0xF8);
3349  00c5 a6f8          	ld	a,#248
3350  00c7 ad9c          	call	_SPI_sendchar
3352                     ; 43 	SPI_sendchar(Lcd_cmd & 0xF0);
3354  00c9 7b01          	ld	a,(OFST+1,sp)
3355  00cb a4f0          	and	a,#240
3356  00cd ad96          	call	_SPI_sendchar
3358                     ; 44 	SPI_sendchar(Lcd_cmd << 4);
3360  00cf 7b01          	ld	a,(OFST+1,sp)
3361  00d1 97            	ld	xl,a
3362  00d2 a610          	ld	a,#16
3363  00d4 42            	mul	x,a
3364  00d5 9f            	ld	a,xl
3365  00d6 ad8d          	call	_SPI_sendchar
3367                     ; 45 	LCD_DELAY()
3370  00d8 9d            nop
3375  00d9 9d            nop
3380  00da 9d            nop
3385  00db 9d            nop
3390  00dc 9d            nop
3392                     ; 46 	E_CLK
3394  00dd 721b5014      	bres	_PE_ODR,#5
3395                     ; 47 	LCD_DELAY()
3398  00e1 9d            nop
3403  00e2 9d            nop
3408  00e3 9d            nop
3413  00e4 9d            nop
3418  00e5 9d            nop
3420                     ; 48 }
3423  00e6 84            	pop	a
3424  00e7 81            	ret
3461                     ; 50 void sendDataST7920(u8 Lcd_data)
3461                     ; 51 {
3462                     	switch	.text
3463  00e8               _sendDataST7920:
3465  00e8 88            	push	a
3466       00000000      OFST:	set	0
3469                     ; 52 	E_CLK
3471  00e9 721b5014      	bres	_PE_ODR,#5
3472                     ; 53 	LCD_DELAY()
3475  00ed 9d            nop
3480  00ee 9d            nop
3485  00ef 9d            nop
3490  00f0 9d            nop
3495  00f1 9d            nop
3497                     ; 54 	E_SET
3499  00f2 721a5014      	bset	_PE_ODR,#5
3500                     ; 55 	SPI_sendchar(0xFA);
3502  00f6 a6fa          	ld	a,#250
3503  00f8 cd0065        	call	_SPI_sendchar
3505                     ; 56 	SPI_sendchar(Lcd_data & 0xF0);
3507  00fb 7b01          	ld	a,(OFST+1,sp)
3508  00fd a4f0          	and	a,#240
3509  00ff cd0065        	call	_SPI_sendchar
3511                     ; 57 	SPI_sendchar(Lcd_data << 4);
3513  0102 7b01          	ld	a,(OFST+1,sp)
3514  0104 97            	ld	xl,a
3515  0105 a610          	ld	a,#16
3516  0107 42            	mul	x,a
3517  0108 9f            	ld	a,xl
3518  0109 cd0065        	call	_SPI_sendchar
3520                     ; 58 	LCD_DELAY()
3523  010c 9d            nop
3528  010d 9d            nop
3533  010e 9d            nop
3538  010f 9d            nop
3543  0110 9d            nop
3545                     ; 59 	E_CLK
3547  0111 721b5014      	bres	_PE_ODR,#5
3548                     ; 60 	LCD_DELAY()
3551  0115 9d            nop
3556  0116 9d            nop
3561  0117 9d            nop
3566  0118 9d            nop
3571  0119 9d            nop
3573                     ; 61 }
3576  011a 84            	pop	a
3577  011b 81            	ret
3623                     ; 63 void refreshLCD(const u8 *lcd_stack)
3623                     ; 64 {
3624                     	switch	.text
3625  011c               _refreshLCD:
3627  011c 89            	pushw	x
3628  011d 88            	push	a
3629       00000001      OFST:	set	1
3632                     ; 66 	sendCodeST7920(0x02);	//地址归位
3634  011e a602          	ld	a,#2
3635  0120 ad95          	call	_sendCodeST7920
3637                     ; 67 	for(addr=0;addr<16;addr++)
3639  0122 0f01          	clr	(OFST+0,sp)
3640  0124               L7722:
3641                     ; 69 		sendDataST7920(*(lcd_stack + addr));
3643  0124 7b02          	ld	a,(OFST+1,sp)
3644  0126 97            	ld	xl,a
3645  0127 7b03          	ld	a,(OFST+2,sp)
3646  0129 1b01          	add	a,(OFST+0,sp)
3647  012b 2401          	jrnc	L62
3648  012d 5c            	incw	x
3649  012e               L62:
3650  012e 02            	rlwa	x,a
3651  012f f6            	ld	a,(x)
3652  0130 adb6          	call	_sendDataST7920
3654                     ; 67 	for(addr=0;addr<16;addr++)
3656  0132 0c01          	inc	(OFST+0,sp)
3659  0134 7b01          	ld	a,(OFST+0,sp)
3660  0136 a110          	cp	a,#16
3661  0138 25ea          	jrult	L7722
3662                     ; 71 	for(addr=32;addr<48;addr++)
3664  013a a620          	ld	a,#32
3665  013c 6b01          	ld	(OFST+0,sp),a
3666  013e               L5032:
3667                     ; 73 		sendDataST7920(*(lcd_stack + addr));
3669  013e 7b02          	ld	a,(OFST+1,sp)
3670  0140 97            	ld	xl,a
3671  0141 7b03          	ld	a,(OFST+2,sp)
3672  0143 1b01          	add	a,(OFST+0,sp)
3673  0145 2401          	jrnc	L03
3674  0147 5c            	incw	x
3675  0148               L03:
3676  0148 02            	rlwa	x,a

⌨️ 快捷键说明

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