Spark Logic

Cannot make OLED display to work with hardware I2C in Adafruit_SSD1306 library

ILI9341 MSP3223 · 14-contact header Pinout
STM32F103C8T6 LQFP48 Pinout
DS3231 SO-16 · 300 mil Pinout

Hi.

This is my first post!

First of all I’d like to say thank you for all the people involved in getting STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog boards to work with the Arduino IDE. I love you all ;)

Now, to my actual issue.

I have a generic STM board (this one) which I am trying to get this OLED (0,96″) display to work though I2C (using Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog library) but I only managed to get it to work using soft I2C (TwoWire class).

Some information:

  • Even though being a software developer I don’t do any embedded work for a living (it is more like a hobby :))
  • This is the code I’ve changed in Adafruit_SSD1306SSD1306Displays, touch panels and LEDs…SPI bus for the tf card from the board anyway. I had one of those 0.96″ oled modules( ssd1306 ) connected to mks sbase v1.3 before I fried the board so I think I’ll try that displ…View in hardware catalog _STM32STM32Microcontrollers and processors…Map magic glue code, ethernet compiles, just WARNING: library LwIP claims to run on [ stm32 ] architecture(s) and may be incompatible with your current board which runs on [STM32]…View in hardware catalog .cpp:
    //HardWire HWIRE(2, I2C_FAST_MODE); // I2c2
    #include <Wire.h>
    TwoWire HWIRE(PB6, PB7, SOFT_FAST);

Replies10

Sat Aug 01, 2015 9:48 pm

Welcome

I would initially try just using the TwoWire rather than Hardwire, its a software implementation that works up to 250kbps ( can probably go faster in the future with some code optimisation), and works on any pins.

I think Hardwire works, but only on specific pins and I think it has some quirks.

However I’m not an expert on Wire, so its probably best to wait for some more people to reply.

Sun Aug 02, 2015 12:33 am

I have only been using software SPI with my OLED projects
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog

Ray

Sun Aug 02, 2015 2:09 pm

RogerClark wrote:Welcome

Sun Aug 02, 2015 2:21 pm

mrburnette wrote:I have only been using software SPI with my OLED projects
https://www.hackster.io/rayburne
But I have used both h/w and s/w SPI with the ILI9341ILI9341Displays, touch panels and LEDs… shows on my screen. I have used and programmed a few different types of SPI screens( ili9341 , st7735) using Python very successfully and these parallel screens have many of the…View in hardware catalog

Tue Sep 27, 2016 10:28 pm

I know this is an old topic, but…

I’m using Blue PillBlue PillDevelopment and computing boards…as become my new favorite board. I am calling it “blue pad” and it is kind of super “ blue pill ”. Pito Thu Jul 27, 2017 8:53 pm [victor_pv – Thu Jul 27, 2017 3:58 pm] – Just for…View in hardware catalog board (STM32F103C8T6STM32F103C8T6Microcontrollers and processors…e Sep 27, 2016 10:28 pm I know this is an old topic, but… I’m using blue pill board ( STM32F103C8T6 , version 3). With the current (modified) Adafruit library 0.96″ OLED display w…View in hardware catalog , version 3). With the current (modified) Adafruit library 0.96″ OLED display works on I2C channel 1 using hardware I2C, but I couldn’t make it to work with channel 2 (which is the default in library). Did someone else had any success with this?

I would use channel 1 (PB6, PB7), but when I do that, RTC DS3231DS3231Memory and real-time clocks…nctions not using that may reduce current draw before peripherals. I will be using a DS3231 . I assume that will mean the systick counter will not be needed? The design for the pe…View in hardware catalog won’t work, since it tries to use software I2C on the same pins. I tried to remap software I2C to other pins, but it doesn’t work (at least not when using Hardwire for OLED) in my case. I tried to modify Sodaq library for this RTC, it works for several seconds after boot, but then the board hangs.

If OLED would work on second I2C channel, it would be great. If not, I would have to go back to Arduino Pro MicroArduino Pro MicroDevelopment and computing boards…c USB CDC ACM that we use I think it was 3 or 4 years ago and I was trying to use an Arduino Pro Micro , and managed to get it to work, but I recall it not just working “out of th…View in hardware catalog for my project, and I would like to avoid that, since F103 offers more RAM. But slow software I2C is very unappealing to me.

Tue Sep 27, 2016 11:29 pm

Software I2C is the default option, so should work on any GPIO pins

But I’m not sure if anyone has tried running the Hardware I2C on anything other than I2C – 1.

There may be a bug in the library where its hard coding something to channel 1.

Wed Sep 28, 2016 1:46 am

I’ll look into that. I kinda don’t want to go back to Pro Micro, and want to explore possibilities of this board.

Wed Sep 28, 2016 6:45 am

search for my oled libraries provided in this forum I think they are also in the repo. HW i2c is working on both, but you need to change it in the library file. I’m sure that I made a comment in the cpp or h file

Sat Oct 01, 2016 7:00 pm

madias wrote:search for my oled libraries provided in this forum I think they are also in the repo. HW i2c is working on both, but you need to change it in the library file. I’m sure that I made a comment in the cpp or h file

Tue Feb 28, 2017 10:04 am

Hi Vagaus!

The Hwire lib hangs, since it enters an endless loop. (see my post hier http://www.stm32duino.com/viewtopic.php?f=14&t=462)
The wire lib hangs too, if the SDA pin does not go HIGH. It s because the polling function of the SDA pin has no exit condition, if the SDA does not go high.
Did you find a solution for your problem?

Post a reply

Optional · up to 10 MiB