The below rather simple code will not operate a 2x16 LCD display that is installed in my EasyPic6 with a 18F4550 MCU. I have studied the examples that came with the EasyPic6 (which work with a 16F887 indicating the EasyPic6 is not the problem), the schematic for the EasyPic6 to make sure I had the port settings correct as used in the EasyPic6/LCD, and the LCDOUT section of the PBP manual. From this I am convinced I have the hardware setup and initalized correctly. I placed the TOGGLE statements in the code to trigger LED's that are on the EasyPic6 as a troubleshooting measure, and they continuously light up in the correct sequence, telling me that the code is actually working through the Main loop. So this made me believe I have some kind of problem with analog settings so used DT's ALLDIGITAL.pbp INCLUDE which I am not sure works with the 18F4550.
I checked the contrast and it is OK so the display's blue backlight turns on and it clears properly during the code, but no words are displayed.
From all of this, I am still not succeeding and am getting frustrated. Can anyone look at this rather simple code and tell me what might be wrong?Code:Define OSC 8 ' LCD DEFINES '============ DEFINE LCD_DREG PORTB ' Use PortB for LCD Data DEFINE LCD_DBIT 4 ' Use lower(4) 4 bits of PortB ' PORTB.0 thru PORTB.3 connects to ' LCD DB4 thru LCD DB-7 respectively DEFINE LCD_RSREG PORTB ' PORTB for RegisterSelect (RS) bit DEFINE LCD_RSBIT 4 ' PORTB.4 pin for LCD's RS line DEFINE LCD_EREG PORTB ' PORTB for Enable (E) bit DEFINE LCD_EBIT 5 ' PORTB.5 pin for LCD's E line DEFINE LCD_BITS 4 ' Using 4-bit bus DEFINE LCD_LINES 2 ' Using 2 line Display DEFINE LCD_COMMANDUS 2000 ' Command Delay (uS) DEFINE LCD_DATAUS 50 ' Data Delay (uS) '** DEFINE LCD Control Constants ** '==================================== I CON 254 ' Control Byte Clr CON 1 ' Clear the display Line1 CON 128 ' Point to beginning of line 1 Line2 CON 192 ' Point to beginning of line 2 ;--- if you un-comment these, you must comment the ones in the .inc file-- ASM ; 18F2550/4550, 8mhz crystal __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _PBADEN_OFF_3H __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L ENDASM ' Initialize Hardware ' ------------------- INCLUDE "ALLDIGITAL.pbp" ' Sets all registers for digital ops. ' User must make sure the AllDigital.pbp file ' is in same directory location as this source ' code before compiling. DEFINE SHOWDITIAL 1 ' When uncommented will show analog settings ' in Assembler Results window. ' A/D & Comparators disabled for digital ops ' All of these statements should be commented out when using the ' INCLUDE "AllDigital.pbp" statement to set digital ops. 'ADRESH = 0 'ADRESL = 0 'ADCON0 = 0 'ADCON1 = %11111111 'ADCON2 = 0 TRISA =%00000000 TRISB =%11111111 TRISC =%00000000 TRISD =%00000000 TRISE =%00000000 PORTB = 0 'Main Loop '========= Main: Pause 2000 ' Delay to let LCD start up TOGGLE PortA.2:Pause 1000 ' For test only...ops comment out LCDOut I,Clr:Pause 1000 ' Clear Display TOGGLEe PortA.3:Pause 1000 ' For test only...ops comment out LCDOut I,Line1+2," TEST " ' Display "TEST" on 1st line LCDOut I,Line2+2,"..Power On.. !!" ' Display "Power on" on 2nd line TOGGLE PortA.4:Pause 1000 ' For test only...ops comment out Goto Main ' Continue loop





Bookmarks