www.elektronik.si Seznam forumov www.elektronik.si
Forum o elektrotehniki in računalništvu
 
 PomočPomoč  IščiIšči  Seznam članovSeznam članov  SkupineSkupine  StatisticsStatistika  AlbumAlbum  DatotekeFilemanager DokumentacijaDocDB LinksPovezave   Registriraj seRegistriraj se 
  PravilaPravila  LinksBolha  PriponkePriponke  KoledarKoledar  ZapiskiZapiski Tvoj profilTvoj profil Prijava za pregled zasebnih sporočilPrijava za pregled zasebnih sporočil PrijavaPrijava 

Bascom lcd4e2.lib sprememba

 
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> Osnove programiranja AVR-jev
Poglej prejšnjo temo :: Poglej naslednjo temo  
Avtor Sporočilo
marko11
Član
Član



Pridružen-a: Ned 14 Dec 2003 17:47
Prispevkov: 866
Aktiv.: 3.90
Kraj: Dobrepolje

PrispevekObjavljeno: Čet Jan 25, 2018 5:49 pm    Naslov sporočila:  Bascom lcd4e2.lib sprememba Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
stursc
Član
Član



Pridružen-a: Tor 08 Jun 2004 14:29
Prispevkov: 323
Aktiv.: 1.45

PrispevekObjavljeno: Čet Jan 25, 2018 8:33 pm    Naslov sporočila:  Re: Bascom lcd4e2.lib sprememba Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
mato1111
Član
Član



Pridružen-a: Pet 28 Dec 2012 14:42
Prispevkov: 610
Aktiv.: 4.45
Kraj: Vrhnika

PrispevekObjavljeno: Čet Jan 25, 2018 8:36 pm    Naslov sporočila:  Re: Bascom lcd4e2.lib sprememba Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo
kose19
Član
Član



Pridružen-a: Sre 02 Mar 2005 19:37
Prispevkov: 1228
Aktiv.: 5.53
Kraj: okolica Kobarida

PrispevekObjavljeno: Čet Jan 25, 2018 8:36 pm    Naslov sporočila:   Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
Jaka57
Moderator
Moderator



Pridružen-a: Ned 12 Dec 2004 21:47
Prispevkov: 5766
Aktiv.: 25.97
Kraj: Grosuplje

PrispevekObjavljeno: Čet Jan 25, 2018 8:43 pm    Naslov sporočila:  Re: Bascom lcd4e2.lib sprememba Odgovori s citatom

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
Skrit Poglej uporabnikov profil Pošlji zasebno sporočilo
marko11
Član
Član



Pridružen-a: Ned 14 Dec 2003 17:47
Prispevkov: 866
Aktiv.: 3.90
Kraj: Dobrepolje

PrispevekObjavljeno: Čet Jan 25, 2018 8:47 pm    Naslov sporočila:  Re: Bascom lcd4e2.lib sprememba Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
marko11
Član
Član



Pridružen-a: Ned 14 Dec 2003 17:47
Prispevkov: 866
Aktiv.: 3.90
Kraj: Dobrepolje

PrispevekObjavljeno: Pet Jan 26, 2018 8:50 pm    Naslov sporočila:   Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
Jaka57
Moderator
Moderator



Pridružen-a: Ned 12 Dec 2004 21:47
Prispevkov: 5766
Aktiv.: 25.97
Kraj: Grosuplje

PrispevekObjavljeno: Pet Jan 26, 2018 9:26 pm    Naslov sporočila:  Re: Bascom lcd4e2.lib sprememba Odgovori s citatom

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.



lcd4e2s.rar
 Opis:

Download
 Ime datoteke:  lcd4e2s.rar
 Velikost datoteke:  2.19 KB
 Downloadano:  3 krat


_________________
Lp, Jaka
Nazaj na vrh
Skrit Poglej uporabnikov profil Pošlji zasebno sporočilo
marko11
Član
Član



Pridružen-a: Ned 14 Dec 2003 17:47
Prispevkov: 866
Aktiv.: 3.90
Kraj: Dobrepolje

PrispevekObjavljeno: Ned Jan 28, 2018 11:37 am    Naslov sporočila:   Odgovori s citatom

@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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
blay44
Član
Član



Pridružen-a: Ned 19 Dec 2010 18:17
Prispevkov: 603
Aktiv.: 3.73

PrispevekObjavljeno: Ned Jan 28, 2018 7:43 pm    Naslov sporočila:   Odgovori s citatom

Jaka57 ti je prepustil še popravek RW pina.
Nazaj na vrh
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
Jaka57
Moderator
Moderator



Pridružen-a: Ned 12 Dec 2004 21:47
Prispevkov: 5766
Aktiv.: 25.97
Kraj: Grosuplje

PrispevekObjavljeno: Ned Jan 28, 2018 9:14 pm    Naslov sporočila:   Odgovori s citatom

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.



lcd4e2s.rar
 Opis:

Download
 Ime datoteke:  lcd4e2s.rar
 Velikost datoteke:  2.22 KB
 Downloadano:  1 krat


_________________
Lp, Jaka
Nazaj na vrh
Skrit Poglej uporabnikov profil Pošlji zasebno sporočilo
marko11
Član
Član



Pridružen-a: Ned 14 Dec 2003 17:47
Prispevkov: 866
Aktiv.: 3.90
Kraj: Dobrepolje

PrispevekObjavljeno: Pet Feb 02, 2018 11:26 am    Naslov sporočila:   Odgovori s citatom

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
Odsoten Poglej uporabnikov profil Pošlji zasebno sporočilo Pošlji E-sporočilo
Pokaži sporočila:   
Objavi novo temo   Odgovori na to temo   Printer-friendly version    www.elektronik.si Seznam forumov -> Osnove programiranja AVR-jev Časovni pas GMT + 2 uri, srednjeevropski - poletni čas
Stran 1 od 1

 
Pojdi na:  
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: 48 dni


Powered by phpBB © 2001, 2005 phpBB Group