Hola Resistencio!
Me gustaria que me dijeran, como hago para leer algun dato (letra - numero - lo que sea...) en el LCD Module...
Hasta donde se, no hey instrucciones basic para leer la memoria del LCD. Si se puede hacer "a mano", con la datasheet del LCD y paciencia.
Si lo que necesitas es ESCRIBIR letras en el LCD, entonces esta parte de la ayuda del PSI te va a servir:
Interfacing character LCDs
Basic compiler also features the support for LCD modules based on HD44780 or compatible controller chip. Prior to using LCD related statements, user should set up LCD interface using DEFINE directives. Here is the list of available parameters:
LCD_BITS - defines the number of data interface lines (allowed values are 4 and 8; default is 4)
LCD_DREG - defines the port where data lines are connected to (default is PORTB)
LCD_DBIT - defines the position of data lines for 4-bit interface (0 or 4; default is 4), ignored for 8-bit interface
LCD_RSREG - defines the port where RS line is connected to (default is PORTB)
LCD_RSBIT - defines the pin where RS line is connected to (default is 3)
LCD_EREG - defines the port where E line is connected to (default is PORTB)
LCD_EBIT - defines the pin where E line is connected to (default is 2)
LCD_RWREG - defines the port where R/W line is connected to (set to 0 if not used; 0 is default)
LCD_RWBIT - defines the pin where R/W line is connected to (set to 0 if not used; 0 is default)
LCD_COMMANDUS - defines the delay after LCDCMDOUT statement (default value is 5000)
LCD_DATAUS - defines the delay after LCDOUT statement (default value is 100)
LCD_INITMS - defines the delay for LCDINIT statement (default value is 100)
The last three parameters should be set to low values when using integrated LCD module simulator. If R/W line is connected to microcontroller and parameter LCD_READ_BUSY_FLAG is set to 1 using DEFINE directive, then these delay parameters will be ignored by compiler and correct timing will be implemented by reading the status of the busy flag in the LCD.
LCDINIT statement should be placed in the program before any of LCDOUT (used for sending data) and LCDCMDOUT (used for sending commands) statements. Its argument is used to define the cursor type: 0 = no cursor (default), 1 = blink, 2 = underline, 3 = blink + underline. LCDOUT and LCDCMDOUT statements may have multiple arguments separated by ','. Strings, constants and variables can be used as arguments of LCDOUT statement. If '#' sign is used before the name of a variable then its decimal representation is sent to the LCD module. Constants and variables can be used as arguments of LCDCMDOUT statement and the following keywords are also available: LcdClear, LcdHome, LcdLine2Home, LcdLeft, LcdRight, LcdShiftLeft, LcdShiftRight, LcdLine1Clear, LcdLine2Clear, LcdLine1Pos() and LcdLine2Pos(). Argument of LcdLine1Pos() and LcdLine2Pos() can be a number in the range (1-40) or Byte data type variable. The value contained in that variable should be in the same range. Here are some examples:
DEFINE LCD_BITS = 8
DEFINE LCD_DREG = PORTB
DEFINE LCD_DBIT = 0
DEFINE LCD_RSREG = PORTD
DEFINE LCD_RSBIT = 1
DEFINE LCD_EREG = PORTD
DEFINE LCD_EBIT = 3
DEFINE LCD_RWREG = PORTD
DEFINE LCD_RWBIT = 2
LCDINIT
loop:
LCDOUT "Hello world!"
WAITMS 1000
LCDCMDOUT LcdClear
WAITMS 1000
GOTO loop
DEFINE LCD_BITS = 8
DEFINE LCD_DREG = PORTB
DEFINE LCD_DBIT = 0
DEFINE LCD_RSREG = PORTD
DEFINE LCD_RSBIT = 1
DEFINE LCD_EREG = PORTD
DEFINE LCD_EBIT = 3
DEFINE LCD_RWREG = PORTD
DEFINE LCD_RWBIT = 2
DIM A AS WORD
A = 65535
LCDINIT 3
WAITMS 1000
loop:
LCDOUT "I am counting!"
LCDCMDOUT LcdLine2Home
LCDOUT #A
A = A - 1
WAITMS 250
LCDCMDOUT LcdClear
GOTO loop
LCD related statements will take control over TRIS registers connected with pins used for LCD interface, but if you use PORTA or PORTE pins on devices with A/D Converter Module then you should take control over the ADCON1 register to set used pins as digital I/O.
You can setup up to eight user defined characters to be used on LCD. This can easily be done with LCDDEFCHAR statement. The first argument of this statement is char number and must be in the range 0-7. Next 8 arguments form 8-line char pattern (from the top to the bottom) and must be in the range 0-31 (5-bits wide). These 8 user characters are assigned to char codes 0-7 and 8-15 and can be displayed using LCDOUT statement. After LCDDEFCHAR statement the cursor will be in HOME position. For example:
LCDDEFCHAR 0, 10, 10, 10, 10, 10, 10, 10, 10
LCDDEFCHAR 1, %11111, %10101, %10101, %10101, %10101,
%10101, %10101, %11111
LCDOUT 0, 1, "Hello!", 1, 0
For LCDs with four lines of characters additional symbolic arguments of LCDCMDOUT statement can be used: LcdLine3Home, LcdLine4Home, LcdLine3Clear, LcdLine4Clear, LcdLine3Pos() and LcdLine4Pos(). Argument of LcdLine3Pos() and LcdLine4Pos() can be a number in the range (1-40) or Byte data type variable. The value contained in that variable should be in the same range. Prior to using these language elements, correct values determining LCD type should be assigned to LCD_LINES and LCD_CHARS parameters using DEFINE directives.
DEFINE LCD_LINES = 4
DEFINE LCD_CHARS = 16
DEFINE LCD_BITS = 8
DEFINE LCD_DREG = PORTB
DEFINE LCD_DBIT = 0
DEFINE LCD_RSREG = PORTD
DEFINE LCD_RSBIT = 1
DEFINE LCD_EREG = PORTD
DEFINE LCD_EBIT = 3
DEFINE LCD_RWREG = PORTD
DEFINE LCD_RWBIT = 2
LCDINIT 3
loop:
LCDCMDOUT LcdClear
LCDCMDOUT LcdLine1Home
LCDOUT "This is line 1"
LCDCMDOUT LcdLine2Home
LCDOUT "This is line 2"
LCDCMDOUT LcdLine3Home
LCDOUT "This is line 3"
LCDCMDOUT LcdLine4Home
LCDOUT "This is line 4"
WAITMS 1000
LCDCMDOUT LcdLine1Clear
LCDCMDOUT LcdLine2Clear
LCDCMDOUT LcdLine3Clear
LCDCMDOUT LcdLine4Clear
LCDCMDOUT LcdLine1Pos(1)
LCDOUT "Line 1"
LCDCMDOUT LcdLine2Pos(2)
LCDOUT "Line 2"
LCDCMDOUT LcdLine3Pos(3)
LCDOUT "Line 3"
LCDCMDOUT LcdLine4Pos(4)
LCDOUT "Line 4"
WAITMS 1000
GOTO loop
Y si tenes paciencia, esta semana justamente voy a escribir los capitulos correspondientes al manejo de LCD alfanumericos. Y la otra, los de 128x64.
Saludos, y avanti con el PSI!
