|
www.elektronik.si Forum o elektrotehniki in računalništvu
|
Poglej prejšnjo temo :: Poglej naslednjo temo |
Avtor |
Sporočilo |
marko11 Član
Pridružen-a: Ned 14 Dec 2003 17:47 Prispevkov: 866 Aktiv.: 3.89 Kraj: Dobrepolje
|
Objavljeno: Čet Jan 25, 2018 5:49 pm Naslov sporočila: Bascom lcd4e2.lib sprememba |
|
|
Hi
Zanima me, če je mogoče popraviti "lcd4e2.lib" datoteko?
Rad bi samo spremenil Rs = PortB.0 ( je sedaj ) na port Rs=PortB.1
To pa zato ker sem pri izdelavi PCB ploščice narobe potegnil vezico.
Prilagam lib datoteko, pa prosim, če je to mogoče, da mi jo nekdo popravi.
lp, marko
Koda: |
copyright = MCS Electronics
www = http://www.mcselec.com
email = avr@mcselec.com
comment = Optimized LCD library
libversion = 1.00
date = 2 februari 2001
statement = No SOURCE code from the library may be distributed in any form
statement = Of course this does not applie for the COMPILED code when you have a BASCOM-AVR license
history = No known bugs.
;the default library for BASCOM can handle worst case scenarios where each pin of the LCD
;is connected to a random pin of the micro
;When we choose the data port pin in sequence, we can save some code
;This lib shows how to use the LCD in 4 bit mode with 2 E lines !
;Rs = PortB.0
;RW = PortB.1 we dont use the R/W option of the LCD in this version so connect to ground
; E = PortB.2
;E2 = PortB.3 for lcd with 2 chips
;Db4 = PortB.4 the data bits must be in a nibble to save code
;Db5 = PortB.5
;Db6 = PortB.6
;Db7 = PortB.7
;This routine is called when the LCD must be initialized
;dont forget to dimension a byte named ___LCDE
[_Init_LCD]
.EQU LCDDDR=$17 ; change to another address for DDRD ($11)
.EQU LCDPORT=$18 ; change to another address for PORTD ($12)
_Init_LCD:
*BASIC: waitms 10
Ldi R24, &B11111111 ; all outputs
Out LCDDDR,R24 ; write to Data direction
Ldi R24, &B00110000 ; set logic level
Out LCDPORT,R24 ; write to output pins
Ldi r16,3 ; repeat 3 times
_Init_LCD1:
SBi LCDPORT, 2 ; E high
Cbi LCDPORT, 2 ; E low
Sbi LCDPORT, 3 ; E2 high
Cbi LCDPORT, 3 ; E2 low
*BASIC: waitms 1
Dec R16
Brne _Init_LCD1 ; until we are ready
Cbi LCDPORT, 4 ; DB4 must be set low now
SBi LCDPORT, 2 ; E high
Cbi LCDPORT, 2 ; E low
Sbi LCDPORT,3 ; E2 high
Cbi LCDPORT,3 ; E2 low
*BASIC: waitms 1
Ldi R24,0
* Sts {___LCDE},R24 ; we use E1 now
Ldi R24, 40 ; 4 bit mode
rcall _Lcd_control
Ldi _temp1,14 ; Display on, Cursor on, Noblink
rcall _Lcd_control
Ldi _temp1,6 ; Cursor moves right, text doesn't move
rcall _Lcd_control
Ldi R24,255
* Sts {___LCDE},R24 ; we use E2 now
Ldi R24, 40 ; 4 bit mode
rcall _Lcd_control
Ldi _temp1,14 ; Display on, Cursor on, Noblink
rcall _Lcd_control
Ldi _temp1,6 ; Cursor moves right, text doesn't move
Rjmp _Lcd_control
[END]
;high nibble must be written first
;rw must be low for a write
;rs must be low for control, high for data
;data passed in r24
[_Write_lcd]
_Write_lcd:
Set ; RS flag must be made 1
Rjmp _Write_lcd_Byte
_Lcd_control:
Clt ; RS flag must be 0
_Write_lcd_Byte:
Mov r25,r24 ; save data
Rcall _Write_lcd_Nibble ; write lower nibble
Mov R24,r25 ; get data back
Swap R24 ; swap nibble
_Write_lcd_nibble:
* Lds R2,{___LCDE}
Tst R2
Brne _Write_lcd_nibble2 ; if E2 selected
Bld R24,0 ; RS flag
Sbr R24,4 ; E high
Cbr R24,10 ; E2 and RW low
Out LCDPORT, R24 ; write
Cbi LCDPORT,2 ; disable
Rjmp _Write_lcd_nibble3
_Write_lcd_nibble2:
Bld R24,0 ; RS flag
Sbr R24,8 ; E high
Cbr R24,6 ; E1 and RW low
Out LCDPORT, R24 ; write
Cbi LCDPORT,3 ; disable
_Write_lcd_nibble3:
@genus(100) ; wait for 100 uS
Ret
[END]
[_CLS]
$EXTERNAL _WRITE_LCD
_Cls:
Ldi R24,1 ; Clear display
Rcall _Lcd_control
*BASIC: waitms 3
Ldi R24,128 ; Select line 1
Rjmp _Lcd_control ; finish
[END]
|
|
|
Nazaj na vrh |
|
|
stursc Član
Pridružen-a: Tor 08 Jun 2004 14:29 Prispevkov: 323 Aktiv.: 1.45
|
Objavljeno: Čet Jan 25, 2018 8:33 pm Naslov sporočila: Re: Bascom lcd4e2.lib sprememba |
|
|
Napiši svoj config
Primer:
Koda: |
Config Lcdpin = Pin , Db7 = PortB.7 , Db6 = PortB.6 , Db5 = PortB.5 , Db4 = PortB.4 , E = PortB.3 , Rs = PortB.2
|
Lp, sturs
|
|
Nazaj na vrh |
|
|
mato1111 Član
Pridružen-a: Pet 28 Dec 2012 14:42 Prispevkov: 612 Aktiv.: 4.45 Kraj: Vrhnika
|
Objavljeno: Čet Jan 25, 2018 8:36 pm Naslov sporočila: Re: Bascom lcd4e2.lib sprememba |
|
|
Jazbi probal tako (sem samo zamenjal pina Rs in RW):
Koda: |
;Rs = PortB.1
;RW = PortB.0 we dont use the R/W option of the LCD in this version so connect to ground
; E = PortB.2
;E2 = PortB.3 for lcd with 2 chips
;Db4 = PortB.4 the data bits must be in a nibble to save code
;Db5 = PortB.5
;Db6 = PortB.6
;Db7 = PortB.7
|
|
|
Nazaj na vrh |
|
|
kose19 Član
Pridružen-a: Sre 02 Mar 2005 19:37 Prispevkov: 1228 Aktiv.: 5.51 Kraj: okolica Kobarida
|
Objavljeno: Čet Jan 25, 2018 8:36 pm Naslov sporočila: |
|
|
Jaz ponavadi na začetku programa konfiguriram na katere pine imam priključen lcd. Poglej kak primer za lcdconfig. Potem ne rabiš knjižnice in tudi nastavitve v settings/lcd nimajo vpliva.
_________________ - Absens, carens -
- Tisti, ki ga ni, bo prikrajšan - |
|
Nazaj na vrh |
|
|
Jaka57 Moderator
Pridružen-a: Ned 12 Dec 2004 21:47 Prispevkov: 5773 Aktiv.: 25.91 Kraj: Grosuplje
|
Objavljeno: Čet Jan 25, 2018 8:43 pm Naslov sporočila: Re: Bascom lcd4e2.lib sprememba |
|
|
mato1111 je napisal/a: |
Jazbi probal tako (sem samo zamenjal pina Rs in RW):
Koda: |
;Rs = PortB.1
;RW = PortB.0 we dont use the R/W option of the LCD in this version so connect to ground
; E = PortB.2
;E2 = PortB.3 for lcd with 2 chips
;Db4 = PortB.4 the data bits must be in a nibble to save code
;Db5 = PortB.5
;Db6 = PortB.6
;Db7 = PortB.7
|
|
S tem nisi naredil popolnoma nič, ker tisto za podpičjem je samo komentar.
marko11 probaj tako kot je napisal stursc.
Je pa nekaj kar se te knjižnjice tiče, ne uporablja pina RW in ga pri LCDju enostavno vežeš na minus:
Koda: |
When you want to have less code you need fixed pins for the LCD display.
With the statement $LIB "LCD4E2.LBX" you specify that the LCD4.LIB will be used.
The following connections are used in the asm code:
Rs = PortB.0
RW = PortB.1 we don’t use the R/W option of the LCD in this version so connect to ground
E = PortB.2
E2 = PortB.3 the second E pin of the LCD
Db4 = PortB.4 the data bits must be in a nibble to save code
Db5 = PortB.5
Db6 = PortB.6
Db7 = PortB.7
You can change the lines from the lcd4e2.lib file to use another port.
Just change the address used :
.EQU LCDDDR=$17 ; change to another address for DDRD ($11)
.EQU LCDPORT=$18 ; change to another address for PORTD ($12) |
Tole zgoraj je napisano na Bascomovi strani.
Mogoče bi bilo najenostavneje popravit tiskanino, tj., prekinit povezavi, eno daš na maso, Rs pa povežeš tako, da bo program deloval.
_________________ Lp, Jaka
Nazadnje urejal/a Jaka57 Čet Jan 25, 2018 8:55 pm; skupaj popravljeno 2 krat |
|
Nazaj na vrh |
|
|
marko11 Član
Pridružen-a: Ned 14 Dec 2003 17:47 Prispevkov: 866 Aktiv.: 3.89 Kraj: Dobrepolje
|
Objavljeno: Čet Jan 25, 2018 8:47 pm Naslov sporočila: Re: Bascom lcd4e2.lib sprememba |
|
|
stursc je napisal/a: |
Napiši svoj config
Primer:
Koda: |
Config Lcdpin = Pin , Db7 = PortB.7 , Db6 = PortB.6 , Db5 = PortB.5 , Db4 = PortB.4 , E = PortB.3 , Rs = PortB.2
|
Lp, sturs |
Nevem če bo to šlo to tako, ker imam 2 LCD-ja in moram preklapljati med E in E2.
|
|
Nazaj na vrh |
|
|
marko11 Član
Pridružen-a: Ned 14 Dec 2003 17:47 Prispevkov: 866 Aktiv.: 3.89 Kraj: Dobrepolje
|
Objavljeno: Pet Jan 26, 2018 8:50 pm Naslov sporočila: |
|
|
Hi
Me pa še vedno zanima, če je možna sprememba v lcd4e2.lib ? da bi bil RS na portB.1,
Rw je pa tako vezan na GND.
lp,
|
|
Nazaj na vrh |
|
|
Jaka57 Moderator
Pridružen-a: Ned 12 Dec 2004 21:47 Prispevkov: 5773 Aktiv.: 25.91 Kraj: Grosuplje
|
Objavljeno: Pet Jan 26, 2018 9:26 pm Naslov sporočila: Re: Bascom lcd4e2.lib sprememba |
|
|
marko11, probaj tole:
Koda: |
copyright = MCS Electronics
www = http://www.mcselec.com
email = avr@mcselec.com
comment = Optimized LCD library
libversion = 1.00
date = 2 februari 2001
statement = No SOURCE code from the library may be distributed in any form
statement = Of course this does not applie for the COMPILED code when you have a BASCOM-AVR license
history = No known bugs.
;the default library for BASCOM can handle worst case scenarios where each pin of the LCD
;is connected to a random pin of the micro
;When we choose the data port pin in sequence, we can save some code
;This lib shows how to use the LCD in 4 bit mode with 2 E lines !
;Rs = PortB.0
;RW = PortB.1 we dont use the R/W option of the LCD in this version so connect to ground
; E = PortB.2
;E2 = PortB.3 for lcd with 2 chips
;Db4 = PortB.4 the data bits must be in a nibble to save code
;Db5 = PortB.5
;Db6 = PortB.6
;Db7 = PortB.7
;This routine is called when the LCD must be initialized
;dont forget to dimension a byte named ___LCDE
[_Init_LCD]
.EQU LCDDDR=$17 ; change to another address for DDRD ($11)
.EQU LCDPORT=$18 ; change to another address for PORTD ($12)
_Init_LCD:
*BASIC: waitms 10
Ldi R24, &B11111111 ; all outputs
Out LCDDDR,R24 ; write to Data direction
Ldi R24, &B00110000 ; set logic level
Out LCDPORT,R24 ; write to output pins
Ldi r16,3 ; repeat 3 times
_Init_LCD1:
SBi LCDPORT, 2 ; E high
Cbi LCDPORT, 2 ; E low
Sbi LCDPORT, 3 ; E2 high
Cbi LCDPORT, 3 ; E2 low
*BASIC: waitms 1
Dec R16
Brne _Init_LCD1 ; until we are ready
Cbi LCDPORT, 4 ; DB4 must be set low now
SBi LCDPORT, 2 ; E high
Cbi LCDPORT, 2 ; E low
Sbi LCDPORT,3 ; E2 high
Cbi LCDPORT,3 ; E2 low
*BASIC: waitms 1
Ldi R24,0
* Sts {___LCDE},R24 ; we use E1 now
Ldi R24, 40 ; 4 bit mode
rcall _Lcd_control
Ldi _temp1,14 ; Display on, Cursor on, Noblink
rcall _Lcd_control
Ldi _temp1,6 ; Cursor moves right, text doesn't move
rcall _Lcd_control
Ldi R24,255
* Sts {___LCDE},R24 ; we use E2 now
Ldi R24, 40 ; 4 bit mode
rcall _Lcd_control
Ldi _temp1,14 ; Display on, Cursor on, Noblink
rcall _Lcd_control
Ldi _temp1,6 ; Cursor moves right, text doesn't move
Rjmp _Lcd_control
[END]
;high nibble must be written first
;rw must be low for a write
;rs must be low for control, high for data
;data passed in r24
[_Write_lcd]
_Write_lcd:
Set ; RS flag must be made 1
Rjmp _Write_lcd_Byte
_Lcd_control:
Clt ; RS flag must be 0
_Write_lcd_Byte:
Mov r25,r24 ; save data
Rcall _Write_lcd_Nibble ; write lower nibble
Mov R24,r25 ; get data back
Swap R24 ; swap nibble
_Write_lcd_nibble:
* Lds R2,{___LCDE}
Tst R2
Brne _Write_lcd_nibble2 ; if E2 selected
Bld R24,1 ; RS flag, spremenil Jaka <-------------
Sbr R24,4 ; E high
Cbr R24,10 ; E2 and RW low
Out LCDPORT, R24 ; write
Cbi LCDPORT,2 ; disable
Rjmp _Write_lcd_nibble3
_Write_lcd_nibble2:
Bld R24,1 ; RS flag, spremenil Jaka <------------------
Sbr R24,8 ; E high
Cbr R24,6 ; E1 and RW low
Out LCDPORT, R24 ; write
Cbi LCDPORT,3 ; disable
_Write_lcd_nibble3:
@genus(100) ; wait for 100 uS
Ret
[END]
[_CLS]
$EXTERNAL _WRITE_LCD
_Cls:
Ldi R24,1 ; Clear display
Rcall _Lcd_control
*BASIC: waitms 3
Ldi R24,128 ; Select line 1
Rjmp _Lcd_control ; finish
[END]
|
Poglej proti koncu knjižnjice, kaj sem spremenil.
Torej, sedaj je RS PortB.1.
V priponki imaš lcd4e2s lib in prevedeno lbx, ki ju razpakiraš v mapo Bascom-AVR\LIB
in jo potem vključiš v svoj program z $LIB "LCD4E2S.LBX".
Na koncu sem dodal s (spremenjena), da ne boš originalne povozil.
Opis: |
|
Download |
Ime datoteke: |
lcd4e2s.rar |
Velikost datoteke: |
2.19 KB |
Downloadano: |
3 krat |
_________________ Lp, Jaka |
|
Nazaj na vrh |
|
|
marko11 Član
Pridružen-a: Ned 14 Dec 2003 17:47 Prispevkov: 866 Aktiv.: 3.89 Kraj: Dobrepolje
|
Objavljeno: Ned Jan 28, 2018 11:37 am Naslov sporočila: |
|
|
@Jaka Sem preizkusil popravljeno Lib, pa NE deluje. Mogoče je potrebno še kje kaj spremeniti.
Jaka hvala za trud. Pač sedaj sem predelal vezje, čeprav ni videti lepo, deluje pa po originalni datoteki.
lp,
_________________ Če ne veš kam greš, se ne moreš zgubiti. |
|
Nazaj na vrh |
|
|
blay44 Član
Pridružen-a: Ned 19 Dec 2010 18:17 Prispevkov: 603 Aktiv.: 3.72
|
Objavljeno: Ned Jan 28, 2018 7:43 pm Naslov sporočila: |
|
|
Jaka57 ti je prepustil še popravek RW pina.
|
|
Nazaj na vrh |
|
|
Jaka57 Moderator
Pridružen-a: Ned 12 Dec 2004 21:47 Prispevkov: 5773 Aktiv.: 25.91 Kraj: Grosuplje
|
Objavljeno: Ned Jan 28, 2018 9:14 pm Naslov sporočila: |
|
|
RW pin MCUja ni vezan na LCD, res pa je, da nisem gledal, kaj se po spremembi dogaja v kodi, oz.,
če še kateri del kode vpliva na Rs pin po spremembi Rs=PortB.1.
Ja in vpliva.
Cbr R24,10 postavi PortB.1(ki je sedaj naš Rs pin) na 0, kar pomeni, da je LCD v ukaznem in ne podatkovnem načinu,
prav tako pa tudi Cbr R24,6, torej je potrebno spremeniti:
Cbr R24,10 v Cbr R24,9 (PortB.3(E2) in PortB.0(RW) bosta 0),
Cbr R24, 6 v Cbr R24,5 (PortB.2(E) in PortB.0(RW) bosta 0).
Spodaj je del, ki je spremenjen:
Koda: |
;high nibble must be written first
;rw must be low for a write
;rs must be low for control, high for data
;data passed in r24
[_Write_lcd]
_Write_lcd:
Set ; RS flag must be made 1
Rjmp _Write_lcd_Byte
_Lcd_control:
Clt ; RS flag must be 0
_Write_lcd_Byte:
Mov r25,r24 ; save data
Rcall _Write_lcd_Nibble ; write lower nibble
Mov R24,r25 ; get data back
Swap R24 ; swap nibble
_Write_lcd_nibble:
* Lds R2,{___LCDE}
Tst R2
Brne _Write_lcd_nibble2 ; if E2 selected
Bld R24,1 ; RS flag <---------- Spremenil Jaka
Sbr R24,4 ; E high
Cbr R24,9 ; E2 and RW low <---------- Spremenil Jaka
Out LCDPORT, R24 ; write
Cbi LCDPORT,2 ; disable
Rjmp _Write_lcd_nibble3
_Write_lcd_nibble2:
Bld R24,1 ; RS flag <---------- Spremenil Jaka
Sbr R24,8 ; E high
Cbr R24,5 ; E1 and RW low <---------- Spremenil Jaka
Out LCDPORT, R24 ; write
Cbi LCDPORT,3 ; disable
_Write_lcd_nibble3:
@genus(100) ; wait for 100 uS
Ret
[END]
|
Marko, s katero Mego se to špilaš?
V prilogi je popravljena knjižnjica lcd4e2s.
Opis: |
|
Download |
Ime datoteke: |
lcd4e2s.rar |
Velikost datoteke: |
2.22 KB |
Downloadano: |
1 krat |
_________________ Lp, Jaka |
|
Nazaj na vrh |
|
|
marko11 Član
Pridružen-a: Ned 14 Dec 2003 17:47 Prispevkov: 866 Aktiv.: 3.89 Kraj: Dobrepolje
|
Objavljeno: Pet Feb 02, 2018 11:26 am Naslov sporočila: |
|
|
Jaka še enkrat hvala.
Sem predelal PCB ploščo, tako da deluje na original knjižnico.
Sedaj delam z Mega128.
Ko bo prilika pa bom sprobal na testni plošči tvojo prenovljeno knjižnico.
Lp,marko
|
|
Nazaj na vrh |
|
|
|
|
Ne, ne moreš dodajati novih tem v tem forumu Ne, ne moreš odgovarjati na teme v tem forumu Ne, ne moreš urejati svojih prispevkov v tem forumu Ne, ne moreš brisati svojih prispevkov v tem forumu Ne ne moreš glasovati v anketi v tem forumu Ne, ne moreš pripeti datotek v tem forumu Ne, ne moreš povleči datotek v tem forumu
|
Uptime: 69 dni
Powered by phpBB © 2001, 2005 phpBB Group
|