Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Libray for character LCD modules (Busy flag/random pins)
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue Aug 03, 2010 7:26 am    Post subject: Reply with quote

Hi,

The LUC_lcd4busy.lib was successfully used with an ATmega48, ATmega168,
ATmega16, ATmega32, ATmega128.

* * *

Test first your LCD module with the standard routines of Bascom. (CONFIG LCDPIN = PIN ....).
When you do that, make sure the R/W pin of the LCD is permanently connected to ground.
When the LCD module works with the standard routines of Bascom, then go back
to the LUC_lcd4busy.lib and connect again the R/W line to the ATmega8.

* * *

Which version of the Bascom compiler are you using?

Best regards,

Luciano
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Tue Aug 03, 2010 1:05 pm    Post subject: Reply with quote

Mr.Luciano, I have 3 modules LCD, 2 LCD 1602A and 1 1602H.
All LCD, have been checked up on ATTyny2313 with "lcd4.lbx",
In standard for Bascom configurations. All LCD works.
p.s. I use the compiler of version 1.11.9.8


Best regards
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue Aug 03, 2010 4:26 pm    Post subject: Reply with quote

Hi,

Try the code below.
(Two configuration statements were added to your sample code).

Read also this post about BUS mode: LINK

Best regards,

Luciano
Code:
$regfile = "m8def.dat"
$crystal = 8000000

$hwstack = 64
$swstack = 40
$framesize = 40

Dim X As Byte

Config LCDMODE = BUS
Config LCDBUS = 4

$lib "LUC_lcd4busy.lib"

Const _lcddb4_portx = Portb                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb4_ddrx = Ddrb                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb4_pinnumber = 0                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb5_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb5_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb5_pinnumber = 7                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb6_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb6_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb6_pinnumber = 6                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcddb7_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb7_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb7_pinx = Pind                                   'Valid values: PINA, PINB, PINC, PIND, PINE.
Const _lcddb7_pinnumber = 5                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcde_portx = Portd                                   'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcde_ddrx = Ddrd                                     'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcde_pinnumber = 1                                   'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcdrw_portx = Portb                                  'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcdrw_ddrx = Ddrb                                    'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcdrw_pinnumber = 3                                  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcdrs_portx = Portb                                  'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcdrs_ddrx = Ddrb                                    'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcdrs_pinnumber = 2                                  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Config Lcd = 16 * 2
Cursor Off Noblink


Main:


Cls

Lcd "Line 1 890123456"
Locate 2 , 1
Lcd "Line 2 890123456"

Waitms 2000


Goto Main

End
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Mon Aug 09, 2010 1:20 pm    Post subject: Reply with quote

Mr. Luciano, so too does not work.
The only thing that has changed, on LCD points, brackets and other dust
There can be you have an opportunity to test on Mega8?
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Mon Aug 09, 2010 5:34 pm    Post subject: Reply with quote

Hi,

I don't have here an ATmega 8 so today I have ordered two chips
ATmega8 an two chips ATmega8A. I will let you know the results
as soon as I receive the chips.

Best regards,

Luciano
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Fri Aug 13, 2010 9:23 am    Post subject: Reply with quote

Hi,

Works OK here with an ATmega8. See attached pictures and attached HEX file.

Try to program your ATmega8 chip with my HEX file. If it does not work, then
verify your hardware.

Best regards,

Luciano

Used code: (The attached HEX file).
Code:
$regfile = "m8def.dat"
$crystal = 8000000

$hwstack = 32
$swstack = 16
$framesize = 40

$lib "LUC_lcd4busy.lib"

Config LCDMODE = BUS ' This will reduce the program space used
Config LCDBUS = 4    ' by the Bascom initialization code.

' LCD   ATmega8
' pin   pin
' ============
' Db4 = PB0
' Db5 = PD7
' Db6 = PD6
' Db7 = PD5
' E  = PD1
' RW = PB3  
' RS = PB2
'
' These are the 22 constants for the above connections:

Const _lcddb4_portx = Portb
Const _lcddb4_ddrx = Ddrb  
Const _lcddb4_pinnumber = 0

Const _lcddb5_portx = Portd
Const _lcddb5_ddrx = Ddrd    
Const _lcddb5_pinnumber = 7

Const _lcddb6_portx = Portd
Const _lcddb6_ddrx = Ddrd  
Const _lcddb6_pinnumber = 6

Const _lcddb7_portx = Portd
Const _lcddb7_ddrx = Ddrd
Const _lcddb7_pinx = Pind
Const _lcddb7_pinnumber = 5

Const _lcde_portx = Portd
Const _lcde_ddrx = Ddrd
Const _lcde_pinnumber = 1

Const _lcdrw_portx = Portb
Const _lcdrw_ddrx = Ddrb
Const _lcdrw_pinnumber = 3

Const _lcdrs_portx = Portb
Const _lcdrs_ddrx = Ddrb
Const _lcdrs_pinnumber = 2

Config Lcd = 16 * 2
Cursor Off Noblink


Do

   Cls
   Waitms 1000

   Lcd "Line 1 890123456"
   Locate 2 , 1
   Lcd "Line 2 890123456"

   Waitms 1000

Loop

End
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Sun Aug 15, 2010 6:38 pm    Post subject: Reply with quote

Thanks, mr. Luciano! I make a board and have a little changed a code.
My two old chips is dead Crying or Very sad
All was started, only the second line does not blink:
Code:


$regfile = "m8def.dat"
$crystal = 8000000

$hwstack = 32
$swstack = 16
$framesize = 40

$lib "LUC_lcd4busy.lib"

Config Lcdmode = Bus                                        ' This will reduce the program space used
Config Lcdbus = 4                                           ' by the Bascom initialization code.

' LCD   ATmega8
' pin   pin
' ============
' Db4 = PD5
' Db5 = PD6
' Db6 = PD7
' Db7 = PB0
' E  = PD1
' RW = PB3
' RS = PB2
'
' These are the 22 constants for the above connections:

Const _lcddb4_portx = Portd
Const _lcddb4_ddrx = Ddrd
Const _lcddb4_pinnumber = 5

Const _lcddb5_portx = Portd
Const _lcddb5_ddrx = Ddrd
Const _lcddb5_pinnumber = 6

Const _lcddb6_portx = Portd
Const _lcddb6_ddrx = Ddrd
Const _lcddb6_pinnumber = 7

Const _lcddb7_portx = Portb
Const _lcddb7_ddrx = Ddrb
Const _lcddb7_pinx = Pinb
Const _lcddb7_pinnumber = 0

Const _lcde_portx = Portd
Const _lcde_ddrx = Ddrd
Const _lcde_pinnumber = 2

Const _lcdrw_portx = Portd
Const _lcdrw_ddrx = Ddrd
Const _lcdrw_pinnumber = 1

Const _lcdrs_portx = Portd
Const _lcdrs_ddrx = Ddrd
Const _lcdrs_pinnumber = 0

Config Lcd = 16 * 2
Cursor Off Noblink


Do

   Cls
   Waitms 1000

   Lcd "Line 1 890123456"
   Locate 2 , 1
   Lcd "Line 2 890123456"

   Waitms 1000

Loop

End
 
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Sun Aug 15, 2010 7:20 pm    Post subject: Reply with quote

Hi,

Increase the contrast and see if the LCD is initialized for two lines or just one line.

Best regards,

Luciano
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Sun Aug 15, 2010 8:00 pm    Post subject: Reply with quote

Second line not work.
Tomorrow I shall order new LCD, and I shall try.
Something inside me speaks: that LCD is dead Brick wall
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Tue Aug 17, 2010 8:38 am    Post subject: Reply with quote

mr. Luciano!
I have removed 2 lines in my code:
Code:

'Config Lcdmode = Bus
'Config Lcdbus = 4
 

and then all has started.
Many thanks for the help!


Last edited by Aleksandr on Tue Aug 17, 2010 11:51 am; edited 1 time in total
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Tue Aug 17, 2010 11:44 am    Post subject: Reply with quote

Its i again ))
One more problem.
After power on, only one line works .
If i reset chip, two lines are started.
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue Aug 17, 2010 3:42 pm    Post subject: Reply with quote

Via fuse bytes you can program a delay after reset or power-up.
The delay can be 0 ms, 4.1 ms or 65 ms. Try with 65 ms.
With this delay you will make sure that the power supply voltage
has reached 5V and that the LCD controller chip present on the LCD
module is ready to receive the data from the AVR.

If that doesn't help, then use the Bascom command INITLCD.

Best regards,

Luciano
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Sun Aug 22, 2010 8:11 pm    Post subject: Reply with quote

Thanks, mr. Luciano!
All my LCD is work!
i use INITLCD.


Code:

$regfile = "m8def.dat"
$crystal = 8000000

$lib "LUC_lcd4busy.lib"

Const _lcddb4_portx = Portd
Const _lcddb4_ddrx = Ddrd
Const _lcddb4_pinnumber = 3

Const _lcddb5_portx = Portd
Const _lcddb5_ddrx = Ddrd
Const _lcddb5_pinnumber = 2

Const _lcddb6_portx = Portd
Const _lcddb6_ddrx = Ddrd
Const _lcddb6_pinnumber = 1

Const _lcddb7_portx = Portd
Const _lcddb7_ddrx = Ddrd
Const _lcddb7_pinx = Pind
Const _lcddb7_pinnumber = 0

Const _lcde_portx = Portd
Const _lcde_ddrx = Ddrd
Const _lcde_pinnumber = 4

Const _lcdrw_portx = Portd
Const _lcdrw_ddrx = Ddrd
Const _lcdrw_pinnumber = 5

Const _lcdrs_portx = Portd
Const _lcdrs_ddrx = Ddrd
Const _lcdrs_pinnumber = 6

Config Lcd = 16 * 2
Initlcd
Cursor Off Noblink




Main:

Cls
Waitms 500
Lcd "12345678980"
Locate 2 , 1
Lcd "12345678980"
Waitms 500

Goto Main

 
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Fri Aug 27, 2010 6:32 pm    Post subject: Reply with quote

Mr.Lachano!
I liked yours idea be relative "LUC_lcd4busy.lib" Applause
May be, you can write new library for buttons?
The requirement: used any pin any quantity of buttons in the keyboard ((an example: for me 6 buttons necessary only => 2 rows and 3 lines or 3 rows and 2 lines)
The rest pins are not necessary
With the best regards,
Aleksandr.
Back to top
View user's profile
Aleksandr

Bascom Member



Joined: 29 Jul 2010
Posts: 15
Location: Russian Federation

russia.gif
PostPosted: Sun Sep 05, 2010 6:18 pm    Post subject: Reply with quote

Hi, Mr.. Luciano!
I have a new question for you))
I use a LCD Winstar WH0802C (8x2) in my project.
Bascom has no configuration to 8x2, and i use the configuration 16x2.
I transmit to the LCD only 8 digits for the first and second lines.
On the screen to change the position of some digits......
My code:


Code:

$regfile = "attiny2313.dat"
$crystal = 8000000
$lib "LUC_lcd4busy.lib"


Const _lcddb4_portx = Portd
Const _lcddb4_ddrx = Ddrd
Const _lcddb4_pinnumber = 2

Const _lcddb5_portx = Portd
Const _lcddb5_ddrx = Ddrd
Const _lcddb5_pinnumber = 5

Const _lcddb6_portx = Portd
Const _lcddb6_ddrx = Ddrd
Const _lcddb6_pinnumber = 4

Const _lcddb7_portx = Portd
Const _lcddb7_ddrx = Ddrd
Const _lcddb7_pinx = Pind
Const _lcddb7_pinnumber = 3

Const _lcde_portx = Portd
Const _lcde_ddrx = Ddrd
Const _lcde_pinnumber = 1

Const _lcdrw_portx = Portd
Const _lcdrw_ddrx = Ddrd
Const _lcdrw_pinnumber = 6

Const _lcdrs_portx = Portd
Const _lcdrs_ddrx = Ddrd
Const _lcdrs_pinnumber = 0

Config Lcd = 16 * 2
Initlcd
Cursor Off Noblink




Do

Lcd "12345678"
Locate 2 , 1
Lcd "87654321"
Waitms 500
Cls
Loop
 



and my LCD: Shocked Shocked
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 3 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum