Backlight PWM help for those using ER-TFTM050-4 LCDs #2194
Replies: 2 comments 2 replies
-
Thanks for posting this. |
Beta Was this translation helpful? Give feedback.
-
I wanted to point out that the reason why I called SetBacklight(0) immediately after the tft.init() is because if you don't, the back light is going to come on briefly if you allow even a few milliseconds to go by before switching off the back light. What ends up happening is a brief bright flash of the display back light on power-up. Turning off the back light immediately prevents this irritating flash. :) It would be best really to have a new driver (or edit the existing one), where the back light is setup with it off. This won't hurt anything if you use the external pin to control the brightness (which I can't recommend). |
Beta Was this translation helpful? Give feedback.
-
So, after contacting East Rising (BUYDISPLAY.COM) with little help and some experimenting (referencing the chipset's datasheet), I finally figured out the mystery of using the built-in PWM driver for this particular display. The external pin that can be driven with PWM does not work properly! It is very sensitive to the frequency vs. duty cycle. I found if you drive the pin 39 (back light control pin) with a 1KHz PWM at anything other than max duty cycle, you get about 60% of the potential brightness. Having pin 39 of these displays as the back light input pin is very inconvenient because you really only need pins 1-16 to be able to have a functioning parallel display. Pins 17-40 are only needed if you want to use a 16 bit wide parallel path and/or the touch screen functions - AND the "BL_ON/OFF" pin 39. I really didn't like having to use a 2x20 cable for this display just to get the back light support, and it turns out that it doesn't work well - AND it is very noisy.
These SSD1963 based displays have an option to use LCD commands to setup and control a PWM signal generated internally to control the back light brighness. This lets you use a 16 pin cable (instead of a 40 pin version) and also gives you very good control of the back light brightness, as well as full brightness potential and with the EMI/RFI greatly reduced because its not going through a potentially long cable (like in my case). To setup the display so you can use the internal commands for control you need to change two jumpers - J3 and J4. By default, the displays come with J3 closed and J4 open. You need to reverse this so that J3 is open and J4 is closed. These are "solder bridge" jumpers. Once you make the change you will need some code in order to enable the back light and control its brightness. The display is kind of weird because it has the ability to ramp up/down the brightness using 3 different stored settings for energy conservation. Conservative seemed to work the best (least amount of flicker), but you can experiment.
Use is simple - just setup the display with 'SetupDisplay()'. This routine sets up the custom registers for the 480 x 272 display. I am sure with some small tweaks (timing registers) that this would also work for the ER-TFTM050-5 which is a 800x400 display. After setting up the display you can set the display brightness between 0 (OFF) and 100% (MAX) by calling 'SetBacklight(xx)'. There is no error checking done here. The actual max brightness is an 8 bit value with 255 being the brightest, but I wanted a percentage instead, which works well. I am also including code that I call FADE IN which ramps the brightness from the current brightness to whatever brightness you want. If the backlight is off (0) then this would fade in from off to some brightness level. There is also FADE OUT that ramps from the current brightness to OFF. These fades are programmed to be fast fade in/out which makes the appearance much nicer than a sudden on or off. You can adjust the prescaler to change the fade in/out speed. You can do things like clear your screen and setup new data while the backlight is off and then fade in to make it reappear. These displays do not handle tearing unless you monitor a pin and write special code just to handle it. I did that and the results were not so great, and I ended up just making these fade in/out routines and switching menu screens this way.
I hope someone finds this useful. Bodmer is welcome to use any/all of this code. I appreciate your hard work - thank you!
Beta Was this translation helpful? Give feedback.
All reactions