# Problem with mega128 and LCD (black boxes)

**URL:** <https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703>\
**Category:** MicroMod\
**Tags:** avr-atmel\
**Created:** [October 9, 2008, 6:04am UTC](https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703 "2008-10-09T06:04:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![digidelia](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@digidelia](https://community.sparkfun.com/u/digidelia)\
**Post date:** [October 9, 2008, 6:04am UTC](https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703/1 "2008-10-09T06:04:09Z")

</div>

i purchased one of the 16x2 HD44780 LCD’s from sparkfun, and i’m having a heck of a time getting it to work with my atmega128 development board.

i’m using bascom to compile the program, and get no errors, but when the program is flashed to the uC, only the first row of black boxes is seen. even after adjusting the contrast, no text is visible.

i’ve tested continuity between pins on the LCD all the way to pins on the uC, i’m positive they go where they’re supposed to. also, i have the R/W hardwired to ground. is there something that i’m doing wrong in the code?

some things i have commented out, to see if it made a difference

any help would be appreciated, thank you

```auto
$regfile = "m128def.dat"
$crystal = 1000000
'$sim
'$lib "lcd4.lbx" ' use the alternative library

Config Porta = Output

Config Lcdpin = Pin , Rs = Porta.6 , E = Porta.4 , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0

Config Lcd = 16 * 2
'Config Lcdmode = Port

'Reset PORTC.0
'set portc.2
'Reset Porta.5 'sets the LCD to write mode

'Main:

'Wait 1
Cls
Lcd "test"
Lowerline
Lcd "12345678"

'Wait 10
'Goto Main

End

```

---

<div class="post-metadata">

**Author:** ![mvs\_sarma](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mvs\_sarma](https://community.sparkfun.com/u/mvs_sarma)\
**Post date:** [October 11, 2008, 9:04am UTC](https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703/2 "2008-10-11T09:04:52Z")

</div>

Though I am not an expert either in in BASCOM or in ATmega, I fear at every character sent to LCD , perhaps a delay routine has to follow. please check the conventions

Is you statement _$crystal =100000_ correct? Are you using 1MHz?

Sarma

---

<div class="post-metadata">

**Author:** ![leon\_heller](https://yyz1.discourse-cdn.com/sparkfun/user_avatar/community.sparkfun.com/leon_heller/32/7602_2.png) [@leon\_heller](https://community.sparkfun.com/u/leon_heller)\
**Post date:** [October 11, 2008, 10:06am UTC](https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703/3 "2008-10-11T10:06:55Z")

</div>

Those LCD displays are very slow.

Leon

---

<div class="post-metadata">

**Author:** ![cschwemin](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@cschwemin](https://community.sparkfun.com/u/cschwemin)\
**Post date:** [October 11, 2008, 7:05pm UTC](https://community.sparkfun.com/t/problem-with-mega128-and-lcd-black-boxes/8703/4 "2008-10-11T19:05:51Z")

</div>

try this site, he uses bascom and 44780 lcds there might be something there.

[http://www.avrprojects.net/articles.php?lng=en&pg=61](http://www.avrprojects.net/articles.php?lng=en&pg=61)

Chris
