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

📄 lcd.lst

📁 ATmega64单片机
💻 LST
📖 第 1 页 / 共 3 页
字号:
   1               		.file	"LCD.c"
   2               	__SREG__ = 0x3f
   3               	__SP_H__ = 0x3e
   4               	__SP_L__ = 0x3d
   5               	__tmp_reg__ = 0
   6               	__zero_reg__ = 1
   7               		.global __do_copy_data
   8               		.global __do_clear_bss
  10               		.text
  11               	.Ltext0:
  88               	.global	lcdSpiSpeedSet
  90               	lcdSpiSpeedSet:
   1:LCD\LCD.c     **** /*****************************************************/
   2:LCD\LCD.c     **** /*            File name : LCD.c                                                   */
   3:LCD\LCD.c     **** /* Description : Code  for Nokia 3310LCD, display IC:PCD8544  */
   4:LCD\LCD.c     **** /* Platform     : AVRStudio4.13 + WinAVR20070525  for AVR     */
   5:LCD\LCD.c     **** /* Author       : Michael Zhang - 章其波                            */
   6:LCD\LCD.c     **** /* Email         : sudazqb@163.com                                          */
   7:LCD\LCD.c     **** /* MSN          : zhangqibo_1985@hotmail.com                          */
   8:LCD\LCD.c     **** /* Date          : 2007-10-21                                                    */
   9:LCD\LCD.c     **** /* NOT FOR COMMERCIAL USE,     ALL RIGHT RESERVED!         */
  10:LCD\LCD.c     **** /*****************************************************/
  11:LCD\LCD.c     **** /* Change Log:                                                                      */
  12:LCD\LCD.c     **** /*                   20071122: fix a bug for some 3310lcd will not work with display function */
  13:LCD\LCD.c     **** /*                   20071021: original version                                 */
  14:LCD\LCD.c     **** /*****************************************************/
  15:LCD\LCD.c     **** 
  16:LCD\LCD.c     **** 
  17:LCD\LCD.c     **** #include"LCD.h"
  18:LCD\LCD.c     **** 
  19:LCD\LCD.c     **** /********************  IO utilities ***************************/
  20:LCD\LCD.c     **** #define LCD_RS_H  LCD_RS_PORT |=   1<<LCD_RS_BIT
  21:LCD\LCD.c     **** #define LCD_RS_L  LCD_RS_PORT &= ~(1<<LCD_RS_BIT)
  22:LCD\LCD.c     **** 
  23:LCD\LCD.c     **** #define LCD_E_H  LCD_E_PORT |=   1<<LCD_E_BIT
  24:LCD\LCD.c     **** #define LCD_E_L  LCD_E_PORT &= ~(1<<LCD_E_BIT)
  25:LCD\LCD.c     **** 
  26:LCD\LCD.c     **** #define LCD_RST_H  LCD_RST_PORT |=   1<<LCD_RST_BIT
  27:LCD\LCD.c     **** #define LCD_RST_L  LCD_RST_PORT &= ~(1<<LCD_RST_BIT)
  28:LCD\LCD.c     **** 
  29:LCD\LCD.c     **** #define LCD_SCK_H  LCD_SCK_PORT |=   1<<LCD_SCK_BIT
  30:LCD\LCD.c     **** #define LCD_SCK_L  LCD_SCK_PORT &= ~(1<<LCD_SCK_BIT)
  31:LCD\LCD.c     **** 
  32:LCD\LCD.c     **** #define LCD_MOSI_H  LCD_MOSI_PORT |=   1<<LCD_MOSI_BIT
  33:LCD\LCD.c     **** #define LCD_MOSI_L  LCD_MOSI_PORT &= ~(1<<LCD_MOSI_BIT)
  34:LCD\LCD.c     **** 
  35:LCD\LCD.c     **** #define PORT_INI {				\
  36:LCD\LCD.c     **** 					LCD_RS_H;	\
  37:LCD\LCD.c     **** 					LCD_E_H;	\
  38:LCD\LCD.c     **** 					LCD_RST_H;	\
  39:LCD\LCD.c     **** 					LCD_SCK_H;	\
  40:LCD\LCD.c     **** 					LCD_MOSI_H;	\
  41:LCD\LCD.c     **** 					LCD_RS_DDR |= 1<<LCD_RS_BIT;	\
  42:LCD\LCD.c     **** 					LCD_E_DDR |= 1<<LCD_E_BIT;	\
  43:LCD\LCD.c     **** 					LCD_RST_DDR |= 1<<LCD_RST_BIT;	\
  44:LCD\LCD.c     **** 					LCD_SCK_DDR |= 1<<LCD_SCK_BIT;	\
  45:LCD\LCD.c     **** 					LCD_MOSI_DDR |= 1<<LCD_MOSI_BIT;	\
  46:LCD\LCD.c     **** 				}
  47:LCD\LCD.c     **** /**************************************************************/
  48:LCD\LCD.c     **** 
  49:LCD\LCD.c     **** 
  50:LCD\LCD.c     **** 
  51:LCD\LCD.c     **** /*********** Display buffer in SRAM ************/
  52:LCD\LCD.c     **** unsigned char disBuf[504];
  53:LCD\LCD.c     **** 
  54:LCD\LCD.c     **** 
  55:LCD\LCD.c     **** 
  56:LCD\LCD.c     **** 
  57:LCD\LCD.c     **** 
  58:LCD\LCD.c     **** #if HW_SPI
  59:LCD\LCD.c     **** /*********************** Hardware SPI Speed Set **************/
  60:LCD\LCD.c     **** void lcdSpiSpeedSet(void)
  61:LCD\LCD.c     **** {
  91               	ze=0) */
  93               	.LM1:
  94               		ldi r24,lo8(80)
  95               		out 45-0x20,r24
  62:LCD\LCD.c     **** 	SPCR =  (1<<SPE) | (1<<MSTR);
  96               	bn	68,0,67,.LM2-.LFBB1
  97               	.LM2:
  98 0000 80E5      		sbi 46-0x20,0
  99 0002 8DB9      	/* epilogue: frame size=0 */
  63:LCD\LCD.c     **** 
  64:LCD\LCD.c     **** #if (F_CPU>8000000)
  65:LCD\LCD.c     **** 	SPSR &= ~(1<<SPI2X);  /* 1/4 F_CPU */
  66:LCD\LCD.c     **** #else
  67:LCD\LCD.c     **** 	SPSR |= 1<<SPI2X;     /* 1/2 F_CPU */
 100               	
 101               	/* epilogue end (size=1) */
 102 0004 709A      	/* function lcdSpiSpeedSet size 4 (3) */
 104 0006 0895      	.Lscope1:
 107               	.global	lcdWriteByte
 109               	lcdWriteByte:
 111               	.LM3:
 112               	.LFBB2:
 113               	/* prologue: frame size=0 */
  68:LCD\LCD.c     **** #endif
  69:LCD\LCD.c     **** }
  70:LCD\LCD.c     **** /************************ Hardware SPI Speed set End *********/
  71:LCD\LCD.c     **** #endif
  72:LCD\LCD.c     **** 
  73:LCD\LCD.c     **** 
  74:LCD\LCD.c     **** /************************ SPI write a byte *********************/
  75:LCD\LCD.c     **** void lcdWriteByte(unsigned char val)
  76:LCD\LCD.c     **** {
 114               	nd (size=0) */
 116               	.LM4:
 117               		out 47-0x20,r24
 118               	.L4:
  77:LCD\LCD.c     **** 	//LCD_E_L;
  78:LCD\LCD.c     **** 	
  79:LCD\LCD.c     **** #if HW_SPI				/* Use Hardware SPI */
  80:LCD\LCD.c     **** 	SPDR = val;
 119               	bn	68,0,81,.LM5-.LFBB2
 120               	.LM5:
 121 0008 8FB9      		sbis 46-0x20,7
 122               		rjmp .L4
  81:LCD\LCD.c     **** 	while(!(SPSR & (1<<SPIF)));	/* Wait transfer end */	
 123               	pilogue: frame size=0 */
 124               		ret
 125 000a 779B      	/* epilogue end (size=1) */
 126 000c 00C0      	/* function lcdWriteByte size 4 (3) */
 128 000e 0895      	.Lscope2:
 131               	.global	lcdWriteCmd
 133               	lcdWriteCmd:
 135               	.LM6:
 136               	.LFBB3:
 137               	/* prologue: frame size=0 */
  82:LCD\LCD.c     **** #else					/* Use common GPIO to simulate the timing*/
  83:LCD\LCD.c     **** 	unsigned char i = 8;
  84:LCD\LCD.c     **** 	while(i--)
  85:LCD\LCD.c     **** 	{
  86:LCD\LCD.c     **** 		LCD_SCK_L;
  87:LCD\LCD.c     **** 		if(val&0x80)LCD_MOSI_H;	/* MSB first */
  88:LCD\LCD.c     **** 		else LCD_MOSI_L;
  89:LCD\LCD.c     **** 		LCD_SCK_H;
  90:LCD\LCD.c     **** 		val <<= 1;				/* Data shift */
  91:LCD\LCD.c     **** 	}
  92:LCD\LCD.c     **** #endif
  93:LCD\LCD.c     **** 
  94:LCD\LCD.c     **** 	//LCD_E_H;
  95:LCD\LCD.c     **** }
  96:LCD\LCD.c     **** /***************************************************************/
  97:LCD\LCD.c     **** 
  98:LCD\LCD.c     **** /************************ SPI write a command *********************/
  99:LCD\LCD.c     **** void lcdWriteCmd(unsigned char val)
 100:LCD\LCD.c     **** {
 138               	 (size=0) */
 140               	.LM7:
 141               		lds r25,98
 142               		andi r25,lo8(-2)
 101:LCD\LCD.c     **** 	//LCD_E_L;
 102:LCD\LCD.c     **** 	LCD_RS_L;
 143               	98,r25
 145 0010 9091 6200 	.LM8:
 146 0014 9E7F      		out 47-0x20,r24
 147 0016 9093 6200 	.L10:
 103:LCD\LCD.c     **** 	
 104:LCD\LCD.c     **** #if HW_SPI				/* Use Hardware SPI */
 105:LCD\LCD.c     **** 	SPDR = val;
 148               	bn	68,0,106,.LM9-.LFBB3
 149               	.LM9:
 150 001a 8FB9      		sbis 46-0x20,7
 151               		rjmp .L10
 106:LCD\LCD.c     **** 	while(!(SPSR & (1<<SPIF)));	/* Wait transfer end */	
 152               	abn	68,0,119,.LM10-.LFBB3
 153               	.LM10:
 154 001c 779B      		lds r24,98
 155 001e 00C0      		ori r24,lo8(1)
 107:LCD\LCD.c     **** #else					/* Use common GPIO to simulate the timing*/
 108:LCD\LCD.c     **** 	unsigned char i = 8;
 109:LCD\LCD.c     **** 	while(i--)
 110:LCD\LCD.c     **** 	{
 111:LCD\LCD.c     **** 		LCD_SCK_L;
 112:LCD\LCD.c     **** 		if(val&0x80)LCD_MOSI_H;	/* MSB first */
 113:LCD\LCD.c     **** 		else LCD_MOSI_L;
 114:LCD\LCD.c     **** 		LCD_SCK_H;
 115:LCD\LCD.c     **** 		val <<= 1;				/* Data shift */
 116:LCD\LCD.c     **** 	}
 117:LCD\LCD.c     **** #endif
 118:LCD\LCD.c     **** 
 119:LCD\LCD.c     **** 	LCD_RS_H;
 156               	 98,r24
 157               	/* epilogue: frame size=0 */
 158 0020 8091 6200 		ret
 159 0024 8160      	/* epilogue end (size=1) */
 160 0026 8093 6200 	/* function lcdWriteCmd size 14 (13) */
 162 002a 0895      	.Lscope3:
 164               	.global	lcdClrDisBuf
 166               	lcdClrDisBuf:
 168               	.LM11:
 169               	.LFBB4:
 170               	/* prologue: frame size=0 */
 120:LCD\LCD.c     **** 	//LCD_E_H;
 121:LCD\LCD.c     **** }
 122:LCD\LCD.c     **** /***************************************************************/
 123:LCD\LCD.c     **** 
 124:LCD\LCD.c     **** 
 125:LCD\LCD.c     **** /***************** LCD initialization *****************************/
 126:LCD\LCD.c     **** void lcdInit(void)
 127:LCD\LCD.c     **** {
 128:LCD\LCD.c     **** 	PORT_INI;		/* IO port initialization*/
 129:LCD\LCD.c     **** 
 130:LCD\LCD.c     **** #if HW_SPI			/* If hardware SPI is used, adjust the SPI speed */
 131:LCD\LCD.c     **** 	lcdSpiSpeedSet();
 132:LCD\LCD.c     **** #endif	
 133:LCD\LCD.c     **** 
 134:LCD\LCD.c     **** 	lcdClrDisBuf();	/* clear display buffer: not the lcd internal buffer */
 135:LCD\LCD.c     **** 
 136:LCD\LCD.c     **** 	_delay_ms(15);	/*MAX F_CPU should below than 16MHz*/
 137:LCD\LCD.c     **** 	_delay_ms(15);
 138:LCD\LCD.c     **** 
 139:LCD\LCD.c     **** 	LCD_RST_L;		/* Reset LCD */
 140:LCD\LCD.c     **** 	_delay_ms(1);
 141:LCD\LCD.c     **** 	LCD_RST_H;
 142:LCD\LCD.c     **** 
 143:LCD\LCD.c     **** 	_delay_us(10);	/* Short Delay */
 144:LCD\LCD.c     **** 
 145:LCD\LCD.c     **** 	LCD_E_L;		/* Enable LCD: CS = 0 */
 146:LCD\LCD.c     **** 
 147:LCD\LCD.c     **** 	lcdWriteCmd(0x21);	/* Expanted Instuction, Set H = 1 */
 148:LCD\LCD.c     **** 	lcdWriteCmd(0xc8);	/* Set bias voltage */
 149:LCD\LCD.c     **** 	lcdWriteCmd(0x06);	/* Set temperature */
 150:LCD\LCD.c     **** 	lcdWriteCmd(0x13);	/* Set 1/48 cycle*/
 151:LCD\LCD.c     **** 	lcdWriteCmd(0x20);	/* Normal Insturction, Set H = 0 */
 152:LCD\LCD.c     **** 	lcdWriteCmd(0x0c);	/* Display control, Normal mode*/
 153:LCD\LCD.c     **** 
 154:LCD\LCD.c     **** 	lcdUpdateDisplay();	/* Update display */
 155:LCD\LCD.c     **** 
 156:LCD\LCD.c     **** 	LCD_E_H;		/* Disable LCD: CS =1 */
 157:LCD\LCD.c     **** }
 158:LCD\LCD.c     **** 
 159:LCD\LCD.c     **** 
 160:LCD\LCD.c     **** /******** Clear the display buffer, external buffer in mico's SRAM ***************/
 161:LCD\LCD.c     **** void lcdClrDisBuf(void)
 162:LCD\LCD.c     **** {
 171               	 (size=0) */
 172               		ldi r30,lo8(disBuf)
 173               		ldi r31,hi8(disBuf)
 174               		rjmp .L16
 175               	.L17:
 177 002e F0E0      	.LM12:
 178 0030 00C0      		st Z+,__zero_reg__
 179               	.L16:
 163:LCD\LCD.c     **** 	unsigned int n = 504;
 164:LCD\LCD.c     **** 	unsigned char * p = disBuf;
 165:LCD\LCD.c     **** 	while(n--)*p++ = 0x00;
 180               	hi8(disBuf+504)
 181               		cpi r30,lo8(disBuf+504)
 182 0032 1192      		cpc r31,r24
 183               		brne .L17
 184 0034 80E0      	/* epilogue: frame size=0 */
 185 0036 E030      		ret
 186 0038 F807      	/* epilogue end (size=1) */
 187 003a 01F4      	/* function lcdClrDisBuf size 9 (8) */
 192               	.Lscope4:
 194               	.global	lcdUpdateDisplay

⌨️ 快捷键说明

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