Un Saludo a las gente de AVR Bascom, esto por aqui esta algo abandonados y estoy abriendo mi Baul donde tengo muchas cosas para hacer con Bascom, esperando que nuestros amigo Olotill venga por aqui y me aclare muchas dudas, de momento estoy haciendo un teclado con LCD y es un Ejempo demo integrado en Bascom pero no consigo simularlo bien para que me salga los display
aqui esta el ejemplo
$regfile "m32def.dat"
$crystal = 8000000
$lib "Lcd_i2c.lib" 'Mi controlador para el LCD
$lib "Key_i2c.lib" 'Mi i2c teclados
$external _key_scan 'activa la routina
Config I2cdelay = 1
Const Pcf8574_lcd = &H40 'Define la direciones de los I/O expander para LCD
Const Pcf8574_kbd = &H42 'Define la direcion de los I/O expander para KBD
!rcall _Key_Init 'llamamos la inicializacion de la routina (necesario si int controla)
Config Scl = Portd.6 'Configura i2c SCL
Config Sda = Portd.7 'Configura i2c SDA
Dim _lcd_e As Byte 'Necesario para control de 4 line del LCD
Dim _key_scan As Byte 'Volvemos a la Tecla desde tecla Scan
Enable Interrupts
Config Int0 = Falling 'Int señal para PCF8574_KBD esta connectedo en INT0
'Enable Int0 'Don't enable until it should be used (after LCD-test)
On Int0 _int0_label 'Procedure to call upon interrupt
'_lcd_e = 128 select E1, 64 select E2, 192 select both (for CLS or DefLCDChar etc.)
_lcd_e = 128 'Upper half of 4-line display is selected
'Here the LCD test program that is included in BASCOM follows
'and at the end there is a demo of the keyboard scan routine
Dim A As Byte
'Config Lcd = 40 * 4 'configure lcd screen
'other options are 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a
'When you dont include this option 16 * 2 is assumed
'16 * 1a is intended for 16 character displays with split addresses over 2 lines
'$LCD = address will turn LCD into 8-bit databus mode
' use this with uP with external RAM and/or ROM
' because it aint need the port pins !
' Put your own strings here
Cls 'clear the LCD display
Lcd "Hello world." 'display this at the top line
Wait 1
Lowerline 'select the lower line
Wait 1
Lcd "Shift this." 'display this at the lower line
Wait 1
For A = 1 To 10
Shiftlcd Right 'mover el texto a la derecha
Waitms 250 'esperar un momento
Next
For A = 1 To 10
Shiftlcd Left 'mover texto a la izquierdad
Waitms 250 'esperar un momento
Next
Locate 2 , 1 'ponemos el Cursor en posicion set cursor position
Lcd "*" 'display esta en
Wait 1 'eperar un momento
Shiftcursor Right 'mover el cursor del display
Lcd "@" 'display esta en
Wait 1 'esperar un momento
Home Upper 'selecionamos linea 1 y retornamos a home
Lcd "Replaced." 'replace el texto
Wait 1 'esperamos un momento
Cursor Off Noblink 'escondemos el curso
Wait 1 'esperamos un momento
Cursor On Blink 'mostramos el cursor
Wait 1 'esperamos un momentos
Display Off 'apagamos el cursor
Wait 1 'esperamos un momentos
Display On 'encendemos el cursor
'-----------------Support for line 3 and 4 is controlled via _lcd_e
_lcd_e = 64
Lcd "Line 3"
Lowerline
Lcd "Line 4"
Wait 1
_lcd_e = 192 'select both halfs for defining characters
'Now lets build a special character
'the first number is the characternumber (0-7)
'The other numbers are the rowvalues
'Use the LCD tool to insert this line
Deflcdchar 2 , 32 , 10 , 32 , 14 , 17 , 17 , 17 , 14 ' replace ? with number (0-7)
Deflcdchar 0 , 32 , 4 , 32 , 14 , 18 , 18 , 18 , 13 ' replace ? with number (0-7)
Deflcdchar 1 , 32 , 10 , 32 , 14 , 18 , 18 , 18 , 13 ' replace ? with number (0-7)
_lcd_e = 128
Cls 'select data RAM
Rem it is important that a CLS is following the deflcdchar statements because it will set the controller back in datamode
Lcd Chr(0) ; Chr(1) 'print the special character
'----------------- Now use an internal routine ------------
_temp1 = 2 'value into ACC
!rCall _write_lcd 'put it on LCD
'Display pressed key value on LCD
Do
Enable Int0 'Now I could accept input from Keyboard
If _key_scan > 0 Then 'As the keyboard is interupt driven I could do like this!
Disable Int0 'Disable Int0 during LCD output due to the fact
Locate 2 , 10 'that _Key_Scan also uses i2c (garbled output is likely)
Lcd _key_scan ; " "
Enable Int0
End If
Loop
End
_int0_label:
!rcall _Key_Scan
Return