HD44780 LCD with PWM LED Backlight control

And voila! As I said in one of the last two posts (Initial post: https://hsel.co.uk/2014/08/14/stm32f0-discovery-board-and-the-hd44780-lcd/ and integrating a charge pump for backlight control: https://hsel.co.uk/2014/08/14/stm32f0-discovery-board-with-hd44780-and-integrated-charge-pump/), I’ve now included a generic LED backlight PWM controller using one of the standard GPIO pins. I’m using GPIOA Pin 6 to drive the LED backlight and I’ve integrated a 4bit (16 step) backlight control within software operating at a PWM frequency of 62.5hz. The PWM counter is implemented within the Systick timer loop, reducing the need for a seperate timer to be enabled, or any specific CC channels used. Theoretically, all the unused pins could be used as PWM outputs, though why you would want to do that, I don’t know! I’d say you could increase the speed at which the PWM runs but this would modify the rate at which the delay function works and that would be undesirable!

Its only a small addition to the code so I’ll merely include pictures. The LED backlight anode is connected to GPIOA pin 6.

Its hard to see but here, the backlight is at minimum brightness.

Here, the screen is on full brightness though its hard to see as the camera flash illuminates the panel itself!

As per, my code can be found in my github repository! If you want one of the previous versions that don’t incorporate the charge pump or LED PWM controller, just use a previous commit!


Charge pump revision without LED PWM: 378109c14b9a259af7ceaef686fd9a1379c8e9bb
Initial revision without chargepump or PWM: b2fe4fa1b742f77ba139043f5f21ac2fcf3b5eac

Enjoy! 🙂

3 thoughts on “HD44780 LCD with PWM LED Backlight control

  1. Hi Harris, I’ve found your HD44780-Library. It was very helpful. Thank you very much for sharing!!
    But I’ve had two little problems with the library.
    – I couldn’t print a single number at he last digit of my LCD
    ( PNum(4,15, 1, 0) displayed nothing )
    – I couldn’t print the number ‘0’
    ( PNum(0, 0, 1, 0) displayed nothing, this is confusing when a value is changing to ‘0’ and the LCD still shows the previous value )

    So I have made two little changes in the function PNum.
    I’ve changed
    ” if(X>((H_XSize-1)-Len)) return -1; ”
    ” if(X>((H_XSize)-Len)) return -1; ”

    For the other issue I’ve added
    ” if (Num == 0) {
    H_W8b(‘0’, 1);
    } ”
    to the function PNum.

    Best regards

Leave a Reply to Jürgen Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s