??? 06/26/08 12:17 Read: times Msg Score: -2 -2 Off-Topic |
#156220 - Problem with Atmega32 + LG322401 GLcd |
Hello friends,
I am working with atmega32 and LG322401 graphic lcd. In this project, i am not getting any o/p on the lcd screen. So if you people have worked with this, then please help me. I have attached my test code. If you have simple demo code, then please provide me. Thanks in advance. Sachin Rathod, Surat.. .include "m32def.inc" .equ RD = 0 .equ WR = 1 .equ A0 = 2 .equ CS = 3 .equ RST = 4 .equ FS1 = 5 .equ DataPort = PORTC .equ CtrlPort = PORTD .equ DataDDR = DDRC .equ CtrlDDR = DDRD .def Temp = r16 .def Dly1 = r17 .def Dly2 = r18 Reset: LDI Temp, 0x5F OUT SPL, Temp LDI Temp, 0x08 OUT SPH, Temp RCALL IOInit RCALL LcdInit Loop: RCALL TestData RCALL Loop Forever: RJMP Forever IOInit: LDI Temp, 0xFF ; r16 = 0xFF OUT DataDDR, Temp ; Lcd data lines o/p dir LDI Temp, 0x3F ; r16 = 0x3F OUT CtrlDDR, Temp ; Lcd ctrl lines o/p dir RET ; Return from subroutine WrLcdCmd: SBI CtrlPort, A0 ; A0 = 1, Select IR OUT DataPort, Temp ; Write command to lcd CBI CtrlPort, WR ; WR = 0 NOP ; No operation NOP ; No operation NOP ; No operation SBI CtrlPort, WR ; WR = 1 RET ; Return from subroutine WrLcdDat: CBI CtrlPort, A0 ; A0 = 0, Select DR OUT DataPort, Temp ; Write command to lcd CBI CtrlPort, WR ; WR = 0 NOP ; No operation NOP ; No operation NOP ; No operation SBI CtrlPort, WR ; WR = 1 RET ; Return from subroutine LcdInit: SBI CtrlPort, RD ; RD = 1 SBI CtrlPort, WR ; WR = 1 CBI CtrlPort, CS ; CS = 0, Enable chip CBI CtrlPort, FS1 ; FS1 = 0, 6x8 dots font selection CBI CtrlPort, RST ; RST = 0 RCALL Dly2ms ; Delay RCALL Dly2ms ; Delay SBI CtrlPort, RST ; RST = 1 RET ; Return from subroutine Dly2ms: PUSH Temp ; Store r16 PUSH Dly1 ; Store r17 PUSH Dly2 ; Store r18 LDI Temp, 0x08 ; r16 = 0x08 Dly2msL1: LDI Dly1, 0xA6 ; r17 = 0xA6 LDI Dly2, 0xA6 ; r18 = 0xA6 Dly2msL2: DEC Dly1 ; Decrement r17 BRNE Dly2msL2 ; Branch if r17 != 0x00 Dly2msL3: DEC Dly2 ; Decrement r18 BRNE Dly2msL3 ; Branch if r18 != 0x00 DEC Temp ; Decrement r16 BRNE Dly2msL1 ; Branch if r16 != 0x00 POP Dly2 ; Retrieve r18 POP Dly1 ; Retrieve r17 POP Temp ; Retrieve r16 RET ; Return from subroutine Clr1stLayer: LDI Temp, 0x46 ; CSRW RCALL WrLcdCmd ; Set cursor address LDI Temp, 0x00 ; Lsb address RCALL WrLcdDat ; Send it LDI Temp, 0x00 ; Msb address RCALL WrLcdDat ; Set 1st address of 1st layer LDI Temp, 0x4C ; CSR DIR RCALL WrLcdCmd ; Set cursor shift direction to right LDI Temp, 0x42 ; MWRITE RCALL WrLcdCmd ; Send it LDI Dly2, 0x08 ; r18 = 8 Rep0x80Times2: LDI Dly1, 0x80 ; r17 = 128 Rep0x80Times: DEC Dly1 ; Decrement r17 LDI Temp, 0x20 ; Space RCALL WrLcdDat ; Send it BRNE Rep0x80Times ; Branch if r17 != 0x00 DEC Dly2 ; Decrement r18 BRNE Rep0x80Times2 ; Branch if r18 != 0x00 RET ; Return from subroutine Clr2ndLayer: LDI Temp, 0x46 ; CSRW RCALL WrLcdCmd ; Set cursor address LDI Temp, 0x00 ; Lsb address RCALL WrLcdDat ; Send it LDI Temp, 0x10 ; Msb address RCALL WrLcdDat ; Set 1st address of 1st layer LDI Temp, 0x4C ; CSR DIR RCALL WrLcdCmd ; Set cursor shift direction to right LDI Temp, 0x42 ; MWRITE RCALL WrLcdCmd ; Send it LDI Dly2, 0x40 ; r18 = 64 Rep0x80Times4: LDI Dly1, 0x80 ; r17 = 128 Rep0x80Times3: DEC Dly1 ; Decrement r17 LDI Temp, 0x00 ; Blank RCALL WrLcdDat ; Send it BRNE Rep0x80Times3 ; Branch if r17 != 0x00 DEC Dly2 ; Decrement r18 BRNE Rep0x80Times4 ; Branch if r18 != 0x00 RET ; Return from subroutine TestData: ; 3 LDI Temp, 0x40 ; System set RCALL WrLcdCmd LDI Temp, 0x38 ; P1 RCALL WrLcdDat LDI Temp, 0x87 ; P2 RCALL WrLcdDat LDI Temp, 0x07 ; P3 RCALL WrLcdDat LDI Temp, 0x3F ; P4 RCALL WrLcdDat LDI Temp, 0x49 ; P5 RCALL WrLcdDat LDI Temp, 0x7F ; P6 RCALL WrLcdDat LDI Temp, 0x80 ; P7 RCALL WrLcdDat LDI Temp, 0x00 ; P8 RCALL WrLcdDat ; 4 LDI Temp, 0x44 ; Scroll RCALL WrLcdCmd LDI Temp, 0x00 ; P1 RCALL WrLcdDat LDI Temp, 0x00 ; P2 RCALL WrLcdDat LDI Temp, 0x40 ; P3 RCALL WrLcdDat LDI Temp, 0x00 ; P4 RCALL WrLcdDat LDI Temp, 0x10 ; P5 RCALL WrLcdDat LDI Temp, 0x40 ; P6 RCALL WrLcdDat LDI Temp, 0x00 ; P7 RCALL WrLcdDat LDI Temp, 0x04 ; P8 RCALL WrLcdDat LDI Temp, 0x00 ; P9 RCALL WrLcdDat LDI Temp, 0x30 ; P10 RCALL WrLcdDat ; 5 LDI Temp, 0x5A ; HDOT SCR RCALL WrLcdCmd LDI Temp, 0x00 ; P1 RCALL WrLcdDat ; 6 LDI Temp, 0x5B ; OVLAY RCALL WrLcdCmd LDI Temp, 0x01 ; P1 RCALL WrLcdDat ; 7 LDI Temp, 0x58 ; DISP ON/OFF RCALL WrLcdCmd LDI Temp, 0x56 ; P1 RCALL WrLcdDat ; 8 RCALL Clr1stLayer ; 9 RCALL Clr2ndLayer ; 10 LDI Temp, 0x46 ; CSRW RCALL WrLcdCmd LDI Temp, 0x00 ; P1 RCALL WrLcdDat LDI Temp, 0x00 ; P2 RCALL WrLcdDat ; 11 LDI Temp, 0x5D ; CSR FORM RCALL WrLcdCmd LDI Temp, 0x04 ; P1 RCALL WrLcdDat LDI Temp, 0x86 ; P2 RCALL WrLcdDat ; 12 LDI Temp, 0x59 ; DISP ON/OFF RCALL WrLcdCmd ; 13 LDI Temp, 0x4C ; CSR DIR RCALL WrLcdCmd ; 14 LDI Temp, 0x42 ; MWRITE RCALL WrLcdCmd LDI Temp, 0x20 ; P1 ' ' RCALL WrLcdDat LDI Temp, 0x45 ; P2 'E' RCALL WrLcdDat LDI Temp, 0x50 ; P3 'P' RCALL WrLcdDat LDI Temp, 0x53 ; P4 'S' RCALL WrLcdDat LDI Temp, 0x4F ; P5 'O' RCALL WrLcdDat LDI Temp, 0x4E ; P6 'N' RCALL WrLcdDat ; 15 LDI Temp, 0x46 ; CSRW RCALL WrLcdCmd LDI Temp, 0x00 ; P1 RCALL WrLcdDat LDI Temp, 0x10 ; P2 RCALL WrLcdDat ; 16 LDI Temp, 0x4F ; CSR DIR RCALL WrLcdCmd ; 17 LDI Temp, 0x42 ; MWRITE RCALL WrLcdCmd LDI Temp, 0xFF ; P1 RCALL WrLcdDat LDI Temp, 0xFF ; P2 RCALL WrLcdDat LDI Temp, 0xFF ; P3 RCALL WrLcdDat LDI Temp, 0xFF ; P4 RCALL WrLcdDat LDI Temp, 0xFF ; P5 RCALL WrLcdDat LDI Temp, 0xFF ; P6 RCALL WrLcdDat LDI Temp, 0xFF ; P7 RCALL WrLcdDat LDI Temp, 0xFF ; P8 RCALL WrLcdDat LDI Temp, 0xFF ; P9 RCALL WrLcdDat ; 18 LDI Temp, 0x46 ; CSRW RCALL WrLcdCmd LDI Temp, 0x01 ; P1 RCALL WrLcdDat LDI Temp, 0x10 ; P2 RCALL WrLcdDat ; 19 LDI Temp, 0x42 ; MWRITE RCALL WrLcdCmd LDI Temp, 0xFF ; P1 RCALL WrLcdDat LDI Temp, 0xFF ; P2 RCALL WrLcdDat LDI Temp, 0xFF ; P3 RCALL WrLcdDat LDI Temp, 0xFF ; P4 RCALL WrLcdDat LDI Temp, 0xFF ; P5 RCALL WrLcdDat LDI Temp, 0xFF ; P6 RCALL WrLcdDat LDI Temp, 0xFF ; P7 RCALL WrLcdDat LDI Temp, 0xFF ; P8 RCALL WrLcdDat LDI Temp, 0xFF ; P9 RCALL WrLcdDat RET |
Topic | Author | Date |
Problem with Atmega32 + LG322401 GLcd | 01/01/70 00:00 | |
Off-Topic! | 01/01/70 00:00 | |
however, this is still valid | 01/01/70 00:00 | |
maybe, just maybe in chat, but not here | 01/01/70 00:00 |