View previous topic :: View next topic |
Author |
Message |
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Wed Mar 30, 2016 3:13 pm Post subject: BASCOM and Serial LCDs |
|
|
I'm having troubles getting a ATMega8 to talk to a variety of LCD modules.
Wiring is as per many website examples with 4 data lines, E, RS, R/W to ground. Voltages and contrast all connected.
Software configures like this...
Config Lcdmode = Port
Config Lcdbus = 4
Rem Config Lcd = 16 * 1a
Config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = Portd.0 , E = Portd.1 , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7
(here set up for a 20x4 screen, alternatively 16*1a which is an 8 x 4)
Now, I have had these screens working in the past with an ATMega32 running at 16Mhz, and a ATMega8 @ 16Mhz.
The ATmega8s I'm using at the moment don't have a crystal connected so are running at the default 1Mhz.
Is there anything in the BASCOM complier that doesn't like that speed. Or do the routines use timer0 or OC1A conflict with using the RXD/TXD for serial connections?
I am running out of ideas, and I can't believe I have wired them up incorrectly so many times?!
Many thanks,
David
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Wed Mar 30, 2016 3:58 pm Post subject: |
|
|
hi ,
I did my own dev board with 40, 28 an 8 avr µC port, it comes from STK200 but all ports are available on HE10 connectors.
I add a 20x 4 lines lcd
for the 40pins micro, I can use port A,B,C,D. here the port D:
Config Lcdmode = Port
Config Lcdpin = Pin , Db4 = Portd.2 , Db5 = Portd.3 , Db6 = Portd.4 , Db7 = Portd.5 , E = Portd.1 , Rs = Portd.0
config Lcd = 20 * 4
These lines are ok for M32,M16, M644....
I saw you write : Quote: | Config Lcdpin = Pin , Rs = Portd.0 , E = Portd.1 , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7
|
the help said :
Quote: | CONFIG LCDPIN = PIN , DB4= PN,DB5=PN, DB6=PN, DB7=PN, E=PN, RS=PN |
E and Rs are at the end of the line , you wrote at the start.
JP |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5921 Location: Holland
|
Posted: Wed Mar 30, 2016 4:04 pm Post subject: |
|
|
you should post a complete but small example of your code, thus show the $regfile, $crystal, etc.
in your code fragment :
Config Lcdmode = Port
Config Lcdbus = 4
Rem Config Lcd = 16 * 1a
Config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = Portd.0 , E = Portd.1 , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7
that is confusing. you connect for PIN mode which is 4 bit by definition.
and it is PIN mode too, so i do not get the lcdmode=port.
just leave out those lines.
you use the tx/rx lines which is fine but : make sure there is no $BAUD or PRINT in your code.
i would not recommend to use the TX/RX as you can not use them for debugging anymore. _________________ Mark |
|
Back to top |
|
|
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Wed Mar 30, 2016 4:23 pm Post subject: |
|
|
Thanks for your speedy replies. I will test some more when I get home this evening. Looks like I might have muddled things in the code.
This is old code I have re-used, so that might be where there are some strange combinations.Code snippet here just for clarification..
Code: |
$regfile = "m8def.dat"
$crystal = 1000000
Config Portd = Output
Config Portc = Input
Config Portb = Output
Portc.0 = 1
Portc.1 = 1
Portd.2 = 1
Portd.3 = 1
Config Lcdmode = Port
Config Lcdbus = 4
Rem Config Lcd = 16 * 1a
Config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = Portd.0 , E = Portd.1 , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7
Dim Answer As Byte
Dim I As Integer
Dim J As Integer
Dim Lcdline As Byte
Dim Lcdtext As String * 25
Dim Lcdwait As Byte
Loop:
Cls
Cursor Off
Lowerline
Lcd " Hello World! "
Wait 5
|
Re the RXD/TXD - I am using serial in and out so there is a $BAUD line and PRINT statements, but I am NOT using the RXD/TXD lies to drive the LCD - I was just wondering if there were timing/timer issues.
I look forward to sorting this a bit later!
Many thanks,
David |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Wed Mar 30, 2016 4:41 pm Post subject: |
|
|
try that
Quote: | $regfile = "m8def.dat"
$crystal = 1000000
Config Lcdmode = Port ' I think this line is not necessary now
Rem Config Lcd = 16 * 1a
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7, Rs = Portd.0 , E = Portd.1
Dim Answer As Byte
Dim I As Integer
Dim J As Integer
Dim Lcdline As Byte
Dim Lcdtext As String * 25
Dim Lcdwait As Byte
' Loop: loop is a reserved word !
Cls
Cursor Off
'Lowerline
locate 4,1 : Lcd " Hello jp! "
Wait 5
end
|
'$baud = 19200 ' whit this statement port D.0 et D.1 are unuable as I/O port , so you cannot use the hard serial link
jp |
|
Back to top |
|
|
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Wed Mar 30, 2016 9:53 pm Post subject: Thank you |
|
|
Thank you!
[img]
http://www.freshpick.co.uk/images/lcd_thank_you_600.jpg
[/img]
Using port B at the moment
Code: |
$regfile = "M8def.dat" 'This tells the compiler which chip we are using
$crystal = 1000000 '16mhz for MR-8
$swstack = 16
$hwstack = 40
config Lcd = 20 * 4
Config Lcdpin = Pin , Rs = PortB.2 , E = PortB.3 , Db4 = PortB.4 , Db5 = PortB.5 , Db6 = PortB.6 , Db7 = PortB.7
wait 3
Cursor Off Noblink
cls
lcd "Thank you, thank you"
locate 2,1
lcd "BASCOM AVR, the best"
locate 3,1
lcd "with a great,helpful"
locate 4,1
lcd "support forum.Thanks"
end
|
Many thanks again,
David |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Thu Mar 31, 2016 9:14 am Post subject: |
|
|
jp |
|
Back to top |
|
|
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Thu Mar 31, 2016 9:46 am Post subject: |
|
|
I moved it all over to port D last night with no problems (D7-D2), leaving D0&D1 available for serial comms.
I need port B now to start to play with SPI, but at least I can "see" what is happening with debug info on the LCD!
Thanks again,
David |
|
Back to top |
|
|
steamydave
Joined: 06 May 2009 Posts: 39
|
Posted: Thu Mar 31, 2016 9:46 am Post subject: |
|
|
I moved it all over to port D last night with no problems (D7-D2), leaving D0&D1 available for serial comms.
I need port B now to start to play with SPI, but at least I can "see" what is happening with debug info on the LCD!
Thanks again,
David |
|
Back to top |
|
|
|
|
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
|
|