
Originally Posted by
luminas
I got my PIC 18F2550 blink an LED, but I cannot write to LCD
LCD is working with other PIC, no hardware issue here
PIC 18F2550, Xtal 10 Mhz
This is my code
Code:
ASM
__CONFIG _CONFIG1L, _PLLDIV_10_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_On_3H & _MCLRE_ON_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
ENDASM
DEFINE OSC 10
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 2 ' LCD data starting bit <font color=red>not valid</font color>
DEFINE LCD_RSREG PORTB ' LCD register select port
DEFINE LCD_RSBIT 0 ' LCD register select bit
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 1 ' LCD enable bit
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' Number lines on LCD
DEFINE LCD_COMMANDUS 2000 ' Command delay time in us
DEFINE LCD_DATAUS 50 ' Data delay time in us
clear
porta = 0
portb = 0
portc = 0
TRISA = %00000000 ' Set PORTA to all output
TRISB = %00000000 ' Set PORTB to all output
TRISC = %00000000 ' Set PORTC to all output
main:
LCDOUT $FE, 1
pause 100
LCDOUT $FE, 1, "Hello "
pause 100
high porta.0
pause 1000
low porta.0
pause 1000
goto main
D bit should be 0 or 4, you cannot use 2 - 5 directly this way, Darrel did do a workaround however . . .
edit: Skimask was quicker on the draw . . .
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks