0

I have issues with electrical noise on my board (>300mV switching noise on top of 3.3V rail, its quite a lot), which is generated by my I2C SSD1306 OLED display. After some research I found that the noise may be reduced by changing the pre-charge duration in the SSD1306 controller. I am using an Arduino IDE with Adafruit_SSD1306.h library to program my chip. As I understand the initialization bits should be passed via I2C to the controller. I found the following command in the Adafrui_SSD1306.cpp:

enter image description here

And the relevant bit of datasheet:

enter image description here

The D9 register is defined as SSD1306_SETPRECHARGE in Adafruit_SSD1306.h:

enter image description here

I am using the following code:

void setup(){
...
display.ssd1306_command(SSD1306_SETPRECHARGE); //0xD9
display.ssd1306_command(0x11);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
}
...

I am trying to set to 0x11, so to give the pre-charge byte lowest value possible. I've also tried putting the same command into the loop. Nothing has any effect on the display brightness though, which from my understanding should decrease with decreasing the pre-charge value. The noise also stays exactly the same. It seems I fail to pass the values to the SSD1306 correctly. I also tried changing the value in the Adafruit_SSD1306.cpp file:

enter image description here

Still no change. The noise stays exactly the same as well as the brightness. It's clear to me I'm doing something wrong, or I misunderstand the effect of changing the pre-charge value completely. I couldn't find anything in adafruit documentation on this matter. What am I doing wrong?

UPDATE:

I used other commands, such as setcontrast, which did have an effect on the display, so I did pass the values to the controller. It seems that changing the pre-charge value do not have much of an effect. On the other hand I discovered that I2C bus might be introducing the unwanted noise. When bypassing the data of clock line to ground via a capacitor the noise decreases. It seems I was looking for an issue in the wrong place.

2
  • At the first glance ssd1306_commad1 should be wrapped in a transaction. This is missing in your code. Add the wrapping macros TRANSACTION_START and TRANSACTION_END or try using ssd1306_command instead.
    – Kwasmich
    Dec 18 '19 at 10:22
  • Apologies, I was using ssd1306_command, forgot to edit it in here. I also discovered that my commands did update the values in the ssd1306 (using other commands like setcontrast etc.), but there was no visible difference when I changed the pre-charge value either in noise or in brightness. Dec 18 '19 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.