| Electronics > Projects, Designs, and Technical Stuff |
| OLED Audible Noise |
| << < (4/4) |
| DenTarda:
Hi catmacey, Thanks for this useful post! Would you be able to share a snippet of code showing how you implement the suggested initialisation commands? I am not an expert and am using the U8g2 library, so I am not sure how to change set Front Clock Divider/Oscillator Frequency or the "pre-charge" voltage :-[ |
| catmacey:
Hi, I've not used U8g2 but it must have a setup function. After a quick google... Yeah it looks to be here https://github.com/olikraus/u8g2/blob/master/csrc/u8x8_d_ssd1327.c There you can see all the initialisation commands. U8X8_CA(....) These are what you want to change. Any way I'm not using that library but here's the initilization sequence code I'm currently using (copied from my project). The _cmd(X) function sets the OLED D/C low for commands and sends a byte via SPI. LCD_RESET_SetHigh/Low() are macros for setting the reset pin on the OLED (yeah I know it says LCD.... ) --- Code: ---void lcd_Init(){ LCD_RESET_SetHigh(); delay_ms(5); LCD_RESET_SetLow(); delay_ms(5); LCD_RESET_SetHigh(); _cmd(0xae); //--turn off oled panel _cmd(0x15); //set column address _cmd(0x00); //start column 0 _cmd(0x7f); //end column 127 _cmd(0x75); //set row address _cmd(0x00); //start row 0 _cmd(0x7f); //end row 127 _cmd(0x81); //set contrast control _cmd(0x50); // _cmd(0x00); _cmd(0xa0); //segment remap _cmd(0x51); //51 _cmd(0xa1); //start line _cmd(0x00); _cmd(0xa2); //display offset _cmd(0x00); _cmd(0xa4); //rmal display _cmd(0xa8); //set multiplex ratio _cmd(0x7f); // TODO: Look at this b1 value and see if the default value of 0xf4 would be better. _cmd(0xb1); //set phase 1 b[3:0] period, and 2 period b[7:4] _cmd(0xf1); // The lower the frequency the less audio noise there is _cmd(0xb3); //set dclk _cmd(0x01); //80Hz:0xc1 90Hz:0xe1 100Hz:0x00 110Hz:0x30 120Hz:0x50 130Hz:0x70 01 _cmd(0xab); // Enable/Disable external VDD. 1 = Enable internal VDD regulator _cmd(0x01); _cmd(0xb6); //set phase length _cmd(0x0f); // Setting this low makes the lowest level dim but visible. // It also makes les audio noise for some reason _cmd(0xbc); // Set precharge voltage. bits [3:0] _cmd(0x03); _cmd(0xbe); // Set VComH voltage. bits [2:0] _cmd(0x5); // Disabling 2nd precharge seems to make less audio noise _cmd(0xd5); // Second precharge b1 = enable 2nd prechage, b0 enable external VSL _cmd(0x60); _cmd(0xb9); // Set default grayscale _cmd(0xfd); // MCU protection status. b2 1 = lock _cmd(0x12); delay_ms(50); //Turn on the OLED display _cmd(0xAF); } --- End code --- |
| DenTarda:
--- Quote ---After a quick google... Yeah it looks to be here https://github.com/olikraus/u8g2/blob/master/csrc/u8x8_d_ssd1327.c There you can see all the initialisation commands. U8X8_CA(....) These are what you want to change. Any way I'm not using that library but here's the initilization sequence code I'm currently using (copied from my project). --- End quote --- Brilliant! Thank you very much for the example and explanations. I will try this! |
| Navigation |
| Message Index |
| Previous page |