How to fix LCD contrast problems on the AVR Butterfly

I had heard a number of reports of contrast problems on the AVR Butterflies produced over the last year. Unfortunately I haven’t had an opportunity to look into this until now. This week while checking some MP3 player code on a new AVR Butterfly I ran into the problem for myself. Luckily it was a simple fix.

A quick search on AVR Freaks turned up the following solution.

Turns out adding the following to lcd_driver.c fixed the problem:

//updated 2006-10-10, setting LCD drive time to 1150us in FW rev 07,
//instead of previous 300us in FW rev 06. Due to some variations on the LCD
//glass provided to the AVR Butterfly production.
LCDCCR |= (1<<LCDDC2) | (1<<LCDDC1) | (1<<LCDDC0);

I inserted these lines as instructed into the file LCD_driver.c at the end of the LCD_Init() function just after gLCD_Update_Required = FALSE; (this is around line 170 for ButterflyMP3).

The change has fixed the problem on my hardware. Although I have updated the files in the CVS, I have not done a general release for either ButterflyMP3 or Butterfly Logger. You can get the modified files directly from the CVS system, here for ButterflyMP3 and here for Butterfly Logger

In addition to the changes given above in the post at AVR Freaks, the macro around line 45 in the file LCD_driver.h

#define LCD_CONTRAST_LEVEL(level) LCDCCR=(0x0F & level)

should be changed to something like

#define LCD_CONTRAST_LEVEL(level) LCDCCR=(0xF0 & LCDCCR) | (0x0F & level)

This change will ensure that the drive time setting does not get erased when using the macro to set the contrast at some time after initialisation. I have not tested this as none of my firmware sets the contrast after startup.

Why are these changes needed?

It appears that the LCD’s characteristics have changed and it now requires a much longer drive time of 1150μs. The original LCD needed only 330μs. I’m unsure of the effect of this on the overall power consumption other than it will increase the LCD’s portion of it.

If the original 330μs drive time is used, then some of the newer LCDs will be very dim and you may only be able to read them at an angle if at all. If you really want to squeeze a little more battery life out of your AVR Butterfly based project then you could have a go at tweaking this value back to 850μs or even 575μs and check the display for readability.

Heres an explanation of what those bits do from the ATMEGA169PA data sheet on page 248.

• Bits 7:5 – LCDDC2:0: LDC Display Configuration
The LCDDC2:0 bits determine the amount of time the LCD drivers are turned on for each voltage transition on segment and common pins. A short drive time will lead to lower power consumption, but displays with high internal resistance may need longer drive time to achieve satisfactory contrast. Note that the drive time will never be longer than one half prescaled LCD clock period, even if the selected drive time is longer. When using static bias or blanking, drive time will always be one half prescaled LCD clock period.

And the accompanying table from the same datasheet also on page 248.

Table 23-7. LCD Display Configuration

LCDDC2LCDDC1LCDDC0Nominal drive time
000300 µs
00170 µs
010150 µs
011450 µs
100575 µs
101850 µs
1101150 µs
11150% of clkLCD_PS

Arduino MP3 Shield Rev B (correct files this time)

I have to apologise to everyone who downloaded the Revision B Arduino MP3 Shield PCBs when I posted them here and here.

I accidently uploaded and emailed everyone the wrong files, not only were they not revision B they weren’t even revision A. This was totally my fault as I grabbed the files from the wrong directory when uploading. I was sure I had checked they were correct but obviously I hadn’t.

I’ve included some pictures of what the layout is supposed to look like for Rev B so you can check the gerbers and EAGLE files are correct before getting any made. ( Look for the large ‘B’ on the top copper layer.)

Figure 1 : Arduino MP3 Shield Rev B PCB - Top view

Figure 2 : Arduino MP3 Shield Rev B PCB - Bottom view

I have since fixed the links and are now hosting the correct files. Here are the links again:

EAGLE files are here

GERBER files are here

Arduino Library files are here

PDF of the schematic is here

Once again sorry to everyone who got the wrong files.

Creative Commons License
Arduino MP3 Shield by Nick Lott is licensed under a Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License.
Based on a work at