📄 增量式模糊控制.lst
字号:
01C0 98C1 CBI 0x18,1
(0063) lcd_clear_rs(); // Set LCD to command
01C1 98C0 CBI 0x18,0
(0064) lcd_set_e(); // Write data to LCD
01C2 9AC2 SBI 0x18,2
(0065) asm("nop");
01C3 0000 NOP
(0066) asm("nop");
01C4 0000 NOP
(0067) lcd_clear_e(); // Disable LCD
01C5 98C2 CBI 0x18,2
(0068) delay_nus(40);
01C6 E208 LDI R16,0x28
01C7 E010 LDI R17,0
01C8 940E00BD CALL _delay_nus
(0069) lcd_set_e(); // Write data to LCD
01CA 9AC2 SBI 0x18,2
(0070) asm("nop");
01CB 0000 NOP
(0071) asm("nop");
01CC 0000 NOP
(0072) lcd_clear_e(); // Disable LCD
01CD 98C2 CBI 0x18,2
(0073) delay_nus(40);
01CE E208 LDI R16,0x28
01CF E010 LDI R17,0
01D0 940E00BD CALL _delay_nus
(0074) LCD_OP_PORT = 0x20;
01D2 E280 LDI R24,0x20
01D3 BB88 OUT 0x18,R24
(0075) lcd_set_e(); // Write data to LCD
01D4 9AC2 SBI 0x18,2
(0076) asm("nop");
01D5 0000 NOP
(0077) asm("nop");
01D6 0000 NOP
(0078) lcd_clear_e(); // Disable LCD
01D7 98C2 CBI 0x18,2
(0079) delay_nus(40);
01D8 E208 LDI R16,0x28
01D9 E010 LDI R17,0
01DA 940E00BD CALL _delay_nus
01DC 9508 RET
_LCD_Busy:
low --> R20
high --> R22
temp --> R10
01DD 940E03F2 CALL push_gset3
(0080) }
(0081) //*****************************************************//
(0082) // This routine will return the busy flag from the LCD //
(0083) //*****************************************************//
(0084) void LCD_Busy ( void )
(0085) {
(0086) unsigned char temp,high;
(0087) unsigned char low;
(0088) LCD_DIR_PORT = 0x0f; // Make I/O Port input
01DF E08F LDI R24,0xF
01E0 BB87 OUT 0x17,R24
(0089) do
(0090) {
(0091) temp=LCD_OP_PORT;
01E1 B2A8 IN R10,0x18
(0092) temp=temp&BIT3;
01E2 2D8A MOV R24,R10
01E3 7088 ANDI R24,0x8
01E4 2EA8 MOV R10,R24
(0093) LCD_OP_PORT=temp;
01E5 BB88 OUT 0x18,R24
(0094) lcd_set_rw(); // Set LCD to READ
01E6 9AC1 SBI 0x18,1
(0095) lcd_clear_rs();
01E7 98C0 CBI 0x18,0
(0096) lcd_set_e();
01E8 9AC2 SBI 0x18,2
(0097) delay_nus(3);
01E9 E003 LDI R16,3
01EA E010 LDI R17,0
01EB 940E00BD CALL _delay_nus
(0098) high = LCD_IP_PORT; // read the high nibble.
01ED B366 IN R22,0x16
(0099) lcd_clear_e(); // Disable LCD
01EE 98C2 CBI 0x18,2
(0100) lcd_set_e();
01EF 9AC2 SBI 0x18,2
(0101) asm("nop");
01F0 0000 NOP
(0102) asm("nop");
01F1 0000 NOP
(0103) low = LCD_IP_PORT; // read the low nibble.
01F2 B346 IN R20,0x16
(0104) lcd_clear_e(); // Disable LCD
01F3 98C2 CBI 0x18,2
(0105) } while(high & 0x80);
01F4 FD67 SBRC R22,7
01F5 CFEB RJMP 0x01E1
(0106) delay_nus(20);
01F6 E104 LDI R16,0x14
01F7 E010 LDI R17,0
01F8 940E00BD CALL _delay_nus
01FA 940E03EB CALL pop_gset3
01FC 9508 RET
_LCD_WriteControl:
temp --> R20
CMD --> R22
01FD 940E03F4 CALL push_gset2
01FF 2F60 MOV R22,R16
(0107) }
(0108) // ********************************************** //
(0109) // *** Write a control instruction to the LCD *** //
(0110) // ********************************************** //
(0111) void LCD_WriteControl (unsigned char CMD)
(0112) {
(0113) char temp;
(0114) LCD_Busy(); // Test if LCD busy
0200 DFDC RCALL _LCD_Busy
(0115) LCD_DIR_PORT = 0xff; // LCD port output
0201 EF8F LDI R24,0xFF
0202 BB87 OUT 0x17,R24
(0116) temp=LCD_OP_PORT;
0203 B348 IN R20,0x18
(0117) temp=temp&BIT3;
0204 7048 ANDI R20,0x8
(0118) LCD_OP_PORT =(CMD & 0xf0)|temp; // Load high-data to port
0205 2F86 MOV R24,R22
0206 7F80 ANDI R24,0xF0
0207 2B84 OR R24,R20
0208 BB88 OUT 0x18,R24
(0119) lcd_clear_rw(); // Set LCD to write
0209 98C1 CBI 0x18,1
(0120) lcd_clear_rs(); // Set LCD to command
020A 98C0 CBI 0x18,0
(0121) lcd_set_e(); // Write data to LCD
020B 9AC2 SBI 0x18,2
(0122) asm("nop");
020C 0000 NOP
(0123) asm("nop");
020D 0000 NOP
(0124) lcd_clear_e(); // Disable LCD
020E 98C2 CBI 0x18,2
(0125) LCD_OP_PORT =(CMD<<4)|temp; // Load low-data to port
020F 2F86 MOV R24,R22
0210 708F ANDI R24,0xF
0211 9582 SWAP R24
0212 2B84 OR R24,R20
0213 BB88 OUT 0x18,R24
(0126) lcd_clear_rw(); // Set LCD to write
0214 98C1 CBI 0x18,1
(0127) lcd_clear_rs(); // Set LCD to command
0215 98C0 CBI 0x18,0
(0128) lcd_set_e(); // Write data to LCD
0216 9AC2 SBI 0x18,2
(0129) asm("nop");
0217 0000 NOP
(0130) asm("nop");
0218 0000 NOP
(0131) lcd_clear_e(); // Disable LCD
0219 98C2 CBI 0x18,2
021A 940E03E8 CALL pop_gset2
021C 9508 RET
_LCD_WriteData:
temp --> R20
Data --> R22
021D 940E03F4 CALL push_gset2
021F 2F60 MOV R22,R16
(0132) }
(0133) // ***************************************** //
(0134) // *** Write one byte of data to the LCD *** //
(0135) // ***************************************** //
(0136) void LCD_WriteData (unsigned char Data)
(0137) {
(0138) char temp;
(0139) LCD_Busy(); // Test if LCD Busy
0220 DFBC RCALL _LCD_Busy
(0140) LCD_DIR_PORT = 0xFF; // LCD port output
0221 EF8F LDI R24,0xFF
0222 BB87 OUT 0x17,R24
(0141) temp=LCD_OP_PORT;
0223 B348 IN R20,0x18
(0142) temp=temp&BIT3;
0224 7048 ANDI R20,0x8
(0143) LCD_OP_PORT =(Data & 0xf0)|temp; // Load high-data to port
0225 2F86 MOV R24,R22
0226 7F80 ANDI R24,0xF0
0227 2B84 OR R24,R20
0228 BB88 OUT 0x18,R24
(0144) lcd_clear_rw() ; // Set LCD to write
0229 98C1 CBI 0x18,1
(0145) lcd_set_rs(); // Set LCD to data
022A 9AC0 SBI 0x18,0
(0146) lcd_set_e(); // Write data to LCD
022B 9AC2 SBI 0x18,2
(0147) asm("nop");
022C 0000 NOP
(0148) asm("nop");
022D 0000 NOP
(0149) lcd_clear_e(); // Disable LCD
022E 98C2 CBI 0x18,2
(0150) LCD_OP_PORT = (Data << 4)|temp; // Load low-data to port
022F 2F86 MOV R24,R22
0230 708F ANDI R24,0xF
0231 9582 SWAP R24
0232 2B84 OR R24,R20
0233 BB88 OUT 0x18,R24
(0151) lcd_clear_rw() ; // Set LCD to write
0234 98C1 CBI 0x18,1
(0152) lcd_set_rs(); // Set LCD to data
0235 9AC0 SBI 0x18,0
(0153) lcd_set_e(); // Write data to LCD
0236 9AC2 SBI 0x18,2
(0154) asm("nop");
0237 0000 NOP
(0155) asm("nop");
0238 0000 NOP
(0156) lcd_clear_e(); // Disable LCD
0239 98C2 CBI 0x18,2
023A 940E03E8 CALL pop_gset2
023C 9508 RET
(0157) }
(0158) // ********************************* //
(0159) // *** Initialize the LCD driver *** //
(0160) // ********************************* //
(0161) void Init_LCD(void)
(0162) {
(0163) LCD_INIT();
_Init_LCD:
023D DF74 RCALL _LCD_INIT
(0164) LCD_WriteControl (LCD_FUNCTION_SET);
023E E208 LDI R16,0x28
023F DFBD RCALL _LCD_WriteControl
(0165) LCD_WriteControl (LCD_OFF);
0240 E008 LDI R16,0x8
0241 DFBB RCALL _LCD_WriteControl
(0166) LCD_WriteControl (LCD_CLEAR);
0242 E001 LDI R16,1
0243 DFB9 RCALL _LCD_WriteControl
(0167) LCD_WriteControl (LCD_MODE_SET);
0244 E006 LDI R16,6
0245 DFB7 RCALL _LCD_WriteControl
(0168) LCD_WriteControl (LCD_ON);
0246 E00C LDI R16,0xC
0247 DFB5 RCALL _LCD_WriteControl
(0169) LCD_WriteControl (LCD_HOME);
0248 E002 LDI R16,2
0249 DFB3 RCALL _LCD_WriteControl
024A 9508 RET
(0170) }
(0171) // ************************************************ //
(0172) // *** Clear the LCD screen (also homes cursor) *** //
(0173) // ************************************************ //
(0174) void LCD_Clear(void)
(0175) {
(0176) LCD_WriteControl(0x01);
_LCD_Clear:
024B E001 LDI R16,1
024C DFB0 RCALL _LCD_WriteControl
024D 9508 RET
(0177) }
(0178) // *********************************************** //
(0179) // *** Position the LCD cursor at row 1, col 1 *** //
(0180) // *********************************************** //
(0181) void LCD_Home(void)
(0182) {
(0183) LCD_WriteControl(0x02);
_LCD_Home:
024E E002 LDI R16,2
024F DFAD RCALL _LCD_WriteControl
0250 9508 RET
_LCD_DisplayCharacter:
Char --> R20
0251 940E03F6 CALL push_gset1
0253 2F40 MOV R20,R16
(0184) }
(0185) // ****************************************************************** //
(0186) // *** Display a single character, at the current cursor location *** //
(0187) // ****************************************************************** //
(0188) void LCD_DisplayCharacter (char Char)
(0189) {
(0190) LCD_WriteData (Char);
0254 2F04 MOV R16,R20
0255 DFC7 RCALL _LCD_WriteData
0256 940E03F9 CALL pop_gset1
0258 9508 RET
_LCD_DisplayString_F:
string --> R20
column --> R10
row --> R22
0259 940E03F2 CALL push_gset3
025B 2EA2 MOV R10,R18
025C 2F60 MOV R22,R16
025D 814E LDD R20,Y+6
025E 815F LDD R21,Y+7
(0191) }
(0192) // ********************************************************************* //
(0193) // *** Display a string at the specified row and column, using FLASH *** //
(0194) // ********************************************************************* //
(0195) void LCD_DisplayString_F (char row, char column , unsigned char *string)
(0196) {
(0197) LCD_Cursor (row, column);
025F 2D2A MOV R18,R10
0260 2F06 MOV R16,R22
0261 D021 RCALL _LCD_Cursor
0262 C004 RJMP 0x0267
(0198) while (*string)
(0199) {
(0200) LCD_DisplayCharacter (*string++);
0263 01FA MOVW R30,R20
0264 9101 LD R16,Z+
0265 01AF MOVW R20,R30
0266 DFEA RCALL _LCD_DisplayCharacter
0267 01FA MOVW R30,R20
0268 8020 LDD R2,Z+0
0269 2022 TST R2
026A F7C1 BNE 0x0263
026B 940E03EB CALL pop_gset3
026D 9508 RET
_LCD_DisplayString:
string --> R20
column --> R10
row --> R22
026E 940E03F2 CALL push_gset3
0270 2EA2 MOV R10,R18
0271 2F60 MOV R22,R16
0272 814E LDD R20,Y+6
0273 815F LDD R21,Y+7
(0201) }
(0202) }
(0203) // ******************************************************************* //
(0204) // *** Display a string at the specified row and column, using RAM *** //
(0205) // ******************************************************************* //
(0206) void LCD_DisplayString (char row, char column ,unsigned char *string)
(0207) {
(0208) LCD_Cursor (row, column);
0274 2D2A MOV R18,R10
0275 2F06 MOV R16,R22
0276 D00C RCALL _LCD_Cursor
0277 C004 RJMP 0x027C
(0209) while (*string)
(0210) LCD_DisplayCharacter (*string++);
0278 01FA MOVW R30,R20
0279 9101 LD R16,Z+
027A 01AF MOVW R20,R30
027B DFD5 RCALL _LCD_DisplayCharacter
027C 01FA MOVW R30,R20
027D 8020 LDD R2,Z+0
027E 2022 TST R2
027F F7C1 BNE 0x0278
0280 940E03EB CALL pop_gset3
0282 9508 RET
_LCD_Cursor:
column --> R20
row --> R22
0283 940E03F4 CALL push_gset2
0285 2F42 MOV R20,R18
0286 2F60 MOV R22,R16
(0211) }
(0212) // *************************************************** //
(0213) // *** Position the LCD cursor at "row", "column". *** //
(0214) // *************************************************** //
(0215) void LCD_Cursor (char row, char column)
(0216) {
(0217) switch (row) {
0287 2777 CLR R23
0288 3061 CPI R22,1
0289 E0E0 LDI R30,0
028A 077E CPC R23,R30
028B F069 BEQ 0x0299
028C 3062 CPI R22,2
028D E0E0 LDI R30,0
028E 077E CPC R23,R30
028F F071 BEQ 0x029E
0290 3063 CPI R22,3
0291 E0E0 LDI R30,0
0292 077E CPC R23,R30
0293 F079 BEQ 0x02A3
0294 3064 CPI R22,4
0295 E0E0 LDI R30,0
0296 077E CPC R23,R30
0297 F081 BEQ 0x02A8
0298 C013 RJMP 0x02AC
(0218) case 1: LCD_WriteControl (0x80 + column - 1); break;
0299 2F04 MOV R16,R20
029A 5800 SUBI R16,0x80
029B 5001 SUBI R16,1
029C DF60 RCALL _LCD_WriteControl
029D C00E RJMP 0x02AC
(0219) case 2: LCD_WriteControl (0xc0 + column - 1); break;
029E 2F04 MOV R16,R20
029F 5400 SUBI R16,0x40
02A0 5001 SUBI R16,1
02A1 DF5B RCALL _LCD_WriteControl
02A2 C009 RJMP 0x02AC
(0220) case 3: LCD_WriteControl (0x94 + column - 1); break;
02A3 2F04 MOV R16,R20
02A4 560C SUBI R16,0x6C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -