Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Libray for character LCD modules (Busy flag/random pins)
Goto page 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: Thu Oct 25, 2007 9:21 pm    Post subject: Libray for character LCD modules (Busy flag/random pins) Reply with quote

Hi,

(Login first).

The attached ZIP file is a libray for character LCD modules.
(HD44780 and compatible controllers).

The LUC_lcd4busy.lib uses the LCD in 4-bit mode and can handle worst
case scenarios where each pin of the LCD is connected to a random pin
of the AVR chip. The library checks the state of the busy flag of the LCD
so the data is sent with the maximal possible speed to the LCD.
(About 15 times faster than what you get with CONFIG LCDPIN where the
code uses fixed delays and the busy flag of the LCD is not used).

The library has no impact on the other pins of the used ports.
The library works with any system clock. (0 to 20MHz).

Use this library at your own risk.

Best regards,

Luciano

Example program:
Code:
' Author: Luciano
' 25 October 2007
'
' (For LCD modules with HD44780 controller or compatible chips).
'
' The LUC_lcd4busy.lib uses the LCD in 4-bit mode and can handle worst
' case scenarios where each pin of the LCD is connected to a random pin
' of the AVR chip. The library checks the state of the busy flag of the LCD
' so the data is sent with the maximal possible speed to the LCD.
' (About 15 times faster than what you get with CONFIG LCDPIN where the
' code uses fixed delays and the busy flag of the LCD is not used).
'
' The library LUC_lcd4busy.lib uses the assembly instructions SBI and CBI.
' These two instructions work only if the addresses of the registers of the
' used ports are smaller than 0x20. This means that the PORTF of an ATmega128
' cannot be used. Note that the new ATmega1281/2561 are not affected by this
' limitation because all the registers of the ports are below address 0x20.
'
' The library has no impact on the other pins of the used ports.
'
' The library works with any system clock. (0 to 20MHz).
'
' The Bascom AVR directive CONFIG LCDPIN is not used and it is replaced by
' the 22 constants you can see below. Below you can see an example of use
' of random pins on five different ports of an ATmega128.
'

$regfile = "m128def.dat"
$crystal = 4000000

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

$lib "LUC_lcd4busy.lib"

' Example of random pins on five different ports of an ATmega128
'
' LCD   AVR
' pin   pin
' ============
' Db4 = PA7
' Db5 = PD0
' Db6 = PE4
' Db7 = PC4
' E  = PC0
' RW = PB1   'Note that RW must be connected to a pin!
' RS = PB4
'
' These are the 22 constants for the above connections:

Const _LcdDB4_PORTx = PortA 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _LcdDB4_DDRx = DDRA   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _LcdDB4_PinNumber = 7 '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 = 0 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _LcdDB6_PORTx = PortE 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _LcdDB6_DDRx = DDRE   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _LcdDB6_PinNumber = 4 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _LcdDB7_PORTx = PortC 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _LcdDB7_DDRx = DDRC   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _LcdDB7_PINx = PinC   'Valid values: PINA, PINB, PINC, PIND, PINE.
Const _LcdDB7_PinNumber = 4 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _LcdE_PORTx = PortC   'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _LcdE_DDRx = DDRC     'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _LcdE_PinNumber = 0   '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 = 1  '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 = 4  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.


'Define the used LCD
Config Lcd = 16 * 2

Cursor Off Noblink
Cls

Config PINC.7 = Output   'Used to measure the time with an oscilloscope. (DSO)

Waitms 1000

LCD "Hello!"
Waitms 1000
Cls
waitms 100

Set portc.7       ' Used to measure the time needed to send "1234567890" to LCD.
LCD "1234567890"  ' 758 microseconds at 4MHz  (0.758 milliseconds).
Reset portc.7     ' (Time measured with the original Hitachi HD44780 chip).


Do
   !nop
Loop

End


EDIT: (16 December 2007)
The attached file LUC_lcd4busy.zip is the version 2.0 of the library.
In the version 2.0 of the library the 3ms delay has been removed
from the _CLS routine. The delay is not necessary because the
library uses the busy flag.

EDIT: (13 August 2010)
At power-up, during the hardware initialization performed by the Bascom
initialization code, the data direction of the pins selected from
"Options/Compiler/LCD" is set. To avoid that, just select the radio
button "Data mode = bus". By doing that, no data direction register will
be changed by the Bascom initialization code to support the LCD so that
you will save some program space. If you go back to the Bascom internal
LCD routines, then you must remember to set "Data mode = pin".
Again, the routine _Init_LCD present in LUC_lcd4busy.lib overrides the
settings present in the Bascom "Options/Compiler/LCD" whatever they are.

EDIT: (8 September 2011)
New library LUC_lcd4busy_timeout.lib with timeout feature.
If the LCD is not connected or if the LCD controller crashes, a timeout will
occur after about 2.33 ms and the execution will go back to the main loop.
The command "Return Home" of an original HD44780 takes max. 1.52ms so with
a 2.33 ms timeout we have some margin of safety.
(At 20 MHz the timeout occurs after 2.33 ms and at 4 MHz after 5.45 ms).

The library and the sample program can be downloaded from the link below.
File LUC_lcd4busy_timeout.zip, 4580 bytes. (Login first).


Last edited by Luciano on Fri Sep 16, 2011 7:16 am; edited 12 times in total
Back to top
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 948
Location: the Netherlands

netherlands.gif
PostPosted: Fri Oct 26, 2007 8:14 pm    Post subject: Reply with quote

Thanks Luciano it works great.

Frank.
Back to top
View user's profile
doc626ge

Bascom Member



Joined: 21 Nov 2005
Posts: 66
Location: USSR

russia.gif
PostPosted: Tue Jul 08, 2008 11:02 am    Post subject: Reply with quote

Hi Luciano
I tryed your lib - works very great and fast! But i find strange LCD behavior with some symbols. I use not only latin symbols, russian symbols (in lcd font list) i use like this for example - Lcd Chr(191), Lcd Chr(187) etc. And then programming mega is done - on lcd i see proper symbols (the programmer connect to mega, AVR910 AVR Prog from Atmel), but when I disconnect programmer from board the symbols on Lcd looks like chinese... I don't know why is happened. If i use standart works with lcd (without busy flag) - lcd works properly and slowly... Why It happened? I very want use your lib... Embarassed

Best regards from Russia
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Tue Jul 08, 2008 12:23 pm    Post subject: Reply with quote

Hi,

Probably an hardware problem.

Please post the schematic of your board + connections to the LCD.
Also need to know the used AVR chip, used clock frequency, used
VCC voltage, used Bascom version and used LCD module.
(Datasheet of the LCD module).

Best regards,

Luciano
Back to top
View user's profile
doc626ge

Bascom Member



Joined: 21 Nov 2005
Posts: 66
Location: USSR

russia.gif
PostPosted: Wed Jul 09, 2008 12:49 pm    Post subject: Reply with quote

Hi Smile
I use mega8 with crystal 8MHz, 5V VCC (7805), Bascom-1.11.9.2 Full Licensed version (same behavior with 1.11.8.8 - 1.11.9.2), try with many LCD: DataVision DV-16236, Winstar WH-1602, WH-1604, WP-1602 (PLED) and Melt MT-16s2d (made in russia), i check hardware many time, without lib (without busy flag) all LCD works well... Connect to LCD:
Code:

Const _lcddb4_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb4_ddrx = Ddrd                                   '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 = 1                                 '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 = 3                                 '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 = 4                                 'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

Const _lcde_portx = Portb                                   'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcde_ddrx = Ddrb                                     'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcde_pinnumber = 2                                   '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 = 1                                  '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 = 0                                  'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

'Define The Used Lcd
Config Lcd = 16 * 2
Cursor Off Noblink
Cls
 

Thanks for your help Smile
Best regards from Russia
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Wed Jul 09, 2008 9:36 pm    Post subject: Reply with quote

Hi,

Works here with three different displays.

When I run the code below I see all the character
patterns present in the ROM of my LCD controllers.
(All three with Japanese standard font table in the ROM).

Code:
Dim Chr_code As Byte

Do

   For Chr_code = 32 to 255
      Cls
      LCD Chr_code ; "=" ; Chr(Chr_code)
      Waitms 1000
   Next Chr_code

Loop


Japanese standard font

(Click to enlarge the picture).

* * *

Just buy an LCD display with the European standard font in the ROM.

Best regards,

Luciano
Back to top
View user's profile
doc626ge

Bascom Member



Joined: 21 Nov 2005
Posts: 66
Location: USSR

russia.gif
PostPosted: Thu Jul 10, 2008 4:17 am    Post subject: Reply with quote

Hi Smile
Luciano wrote:
Just buy an LCD display with the European standard font in the ROM

All my Lcd have a standart European font in the ROM. I'll try work with lib again, maybe my mistake there... Thank U for your help Smile
Best regards from Russia
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Thu Jul 10, 2008 7:17 am    Post subject: Reply with quote

Hi,

Example of LCD selector guide:

(Click to enlarge the picture).

Best regards,

Luciano
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Thu Jul 10, 2008 2:59 pm    Post subject: Reply with quote

Hi folks

I had simular problems: LCD works fine with standard lib and R/W grounded, but didn't want to run with Luciano's lib.
So I took the LCD datasheet and worked all the way down through Luciano's lib. And (frankly, I expected that Wink ) he did a perfect job. So the lib itself is fine. Uh ... more than fine ... it's fast and allows freedom in pin-choice.
What I found: if the pin-definition in Options - Compiler - LCD do not match with what is defined in Luciano's block, the LCD doesn't work. So I added Configlcd in my program, and now it's all fine. (see attached snapshot)
One more tip: since the 44780 generates its own reset, it's unknown who will be first up and running: 44780 or AVR. To prevent mis-initialisation I added 1k pull-downs on E and R/W. The value is arbitrary: 4k7 will be OK as well.

Thanks Luciano, for this fabulous library !

Nard

Code:

....

$lib "LUC_lcd4busy.lib"

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


'Leave this Config in: it overrules the setting in Options-Compiler-LCD.
'When those settings differ from what is defined in Luciano's block, the LCD won't work.
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.3
Config Lcd = 20 * 2

 

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Thu Jul 10, 2008 5:18 pm    Post subject: Reply with quote

Hi,

(While using the library LUC_lcd4busy.lib).

"Config Lcdpin" is not required and what you have in the Bascom Options - Compiler - LCD doesn’t matter.
"Config Lcd" is required because Bascom must know the internal addresses of the LCD.

The code compiled with the LIB will not work in the Bascom simulator because the LCD of the Bascom
simulator does not support the busy flag.

In the LIB there is a 40ms delay (LCD power-up delay) so a mis-initialisation of the LCD at
power-up is not possible. The LCD controller has internal MOS pull-up's on the lines RS and R/W
so even if the LCD powers-up before the AVR, the LCD will be in 8-bit mode and the lines RS and R/W
will be pulled up by the internal MOS pull-Up's. RS=1 and R/W=1 is a READ for the LCD controller and
therefore there is no problem at all.

Best regards,

Luciano
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Thu Jul 10, 2008 8:16 pm    Post subject: Reply with quote

I don't agree with you Luciano. For the simple reason that with the line
Code:
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.3  
my code works, and without it doesn't. Problem is the lower line, as you can see in the attached pictures.
I am not talking about compilation-problems or simulator issues: this is real life proof: compiled, programmed, target-system powered down, then powered up.

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Thu Jul 10, 2008 8:46 pm    Post subject: Reply with quote

Hi Nard,

(You are using a 2*20 LCD).

"Config Lcd = 20 * 2" must be present in the code.

* * *

Can you please post the 22 constants used by the LIB?
Which AVR chip are you using?

Best regards,

Luciano
Back to top
View user's profile
Plons

Bascom Member



Joined: 24 May 2005
Posts: 435
Location: Hilversum - The Netherlands

netherlands.gif
PostPosted: Thu Jul 10, 2008 11:17 pm    Post subject: Reply with quote

Hi Luciano,

Code:
'19200 Baud is about as fast as it gets: optocouplers 4N35 are slow ...
Const Comm_speed = 19200

$baud = Comm_speed
$crystal = 16000000
$regfile = "m168def.dat"

'Heavily overdone .... but who cares ....
$hwstack = 64
$swstack = 40
$framesize = 40

'$PROG &HFF,&HFF,&HD4,&HF8' generated. Take care that the chip supports all fuse bytes.

Dim Status As Byte
Status_powerfail Alias Status.7
Fluffie Alias Status.6
Terminal Alias Status.5                                     'Set when a terminal is connected & takes command
Transpose Alias Status.4                                    'Set when answers from Iso's are translated to ID-Iso+6
Status_watchdog Alias Status.3
Status_brownout Alias Status.2
Status_ext_reset Alias Status.1
Status_pwr_on_reset Alias Status.0
'Since it seems to be impossible to fetch the MCUCSR-watchdog-flag, we use this:
Status = Peek(0)

$lib "LUC_lcd4busy.lib"

Const _lcddb4_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb4_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb4_pinnumber = 4                                 '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 = 5                                 '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 = 7                                 '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 = 2                                   'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

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

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

'/   cutout////////////////////////////////

'Leave this Config in: it overrules the setting in Options-Compiler-LCD.
'When those settings differ from what is defined in Luciano's block, the LCD won't work.
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.3
Config Lcd = 20 * 2

'Timer0 is the system-counter, and the Conductor of the Communication-Orchestra
Tccr0a = &H00                                               'for M168
Tccr0b = &HF3                                               'for M168
'Tccr0 = &HF3                                                'for M8
Enable Ovf0
On Ovf0 Ms_int Nosave

etc ....

 


I used a Mega8 and now the M168 as AVR.
The display is a 44780 compatible OLED display.
The only thing I changed in the programs above is that I commented out the line:
Code:
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.2 , Rs = Portd.3
Config Lcd = 20 * 2 was in in both programs. So that *should* overrule the setting 16*1a in Options - Compiler - LCD
Screenshot attached.

Cheers

Nard

_________________
Bascom AVR ver 2.0.8.6
Dragon-lair: http://www.aplomb.nl/TechStuff/Dragon/Dragon.html
"leef met vlag en wimpel, maar hou het simpel"
Back to top
View user's profile
Luciano

Bascom Member



Joined: 29 Nov 2004
Posts: 3149
Location: Italy

blank.gif
PostPosted: Fri Jul 11, 2008 8:45 am    Post subject: Reply with quote

Hi Nard,

I have tested with the code below (your configuration) and it works.
As you can see "Config Lcdpin" is not present in the code.
I have also set the Bascom Options - Compiler - LCD like your
screenshot but, as expected, it doesn’t matter.

Tested with an ATmega48, STK500, 2*20 LCD and Bascom 1.11.9.2.

(This is part of the code you have posted).
Code:
'19200 Baud is about as fast as it gets: optocouplers 4N35 are slow ...
Const Comm_speed = 19200

$baud = Comm_speed
$crystal = 16000000
$regfile = "m48def.dat"

'Heavily overdone .... but who cares ....
$hwstack = 64
$swstack = 40
$framesize = 40

'$PROG &HFF,&HFF,&HD4,&HF8' generated. Take care that the chip supports all fuse bytes.

Dim Status As Byte
Status_powerfail Alias Status.7
Fluffie Alias Status.6
Terminal Alias Status.5                                     'Set when a terminal is connected & takes command
Transpose Alias Status.4                                    'Set when answers from Iso's are translated to ID-Iso+6
Status_watchdog Alias Status.3
Status_brownout Alias Status.2
Status_ext_reset Alias Status.1
Status_pwr_on_reset Alias Status.0
'Since it seems to be impossible to fetch the MCUCSR-watchdog-flag, we use this:
Status = Peek(0)

$lib "LUC_lcd4busy.lib"

Const _lcddb4_portx = Portd                                 'Valid values: PORTA, PORTB, PORTC, PORTD, PORTE.
Const _lcddb4_ddrx = Ddrd                                   'Valid values: DDRA, DDRB, DDRC, DDRD, DDRE.
Const _lcddb4_pinnumber = 4                                 '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 = 5                                 '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 = 7                                 '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 = 2                                   'Valid values: 0, 1, 2, 3, 4, 5, 6, 7.

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

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

Config Lcd = 20 * 2
Cursor Off Noblink
Cls

LCD "Line 1 1234567890123"
Locate 2,1
LCD "Line 2 1234567890123"

Do
 !NOP
Loop

End

The result of the test with the above code:

(Click to enlarge the picture)

Best regards,

Luciano
Back to top
View user's profile
PaulC

Bascom Member



Joined: 09 Jan 2008
Posts: 122
Location: Ireland

ireland.gif
PostPosted: Fri Jul 11, 2008 11:50 am    Post subject: thankyou Reply with quote

thankyou Luciano
will give this a go

_________________
Bascom Avr 2.0.7.3
Works for me


Last edited by PaulC on Fri Sep 09, 2011 2:12 am; edited 1 time in total
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 1, 2, 3, 4, 5  Next
Page 1 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