GrumpyOldPizza / arduino-STM32L4

69 stars 60 forks source link

I2C issue #35

Closed tcsaba101 closed 6 years ago

tcsaba101 commented 6 years ago

Dear Kris & Thomas, I have a limited experience in Atmel AVR, ESP32, chipkit PIC development, mainly Arduino, some MPXlab, Atmelstudio + Atmel-ICE platforms. I like Arduino, because of simplicity.

I am kickstarting in STM32 on your platform. Blink was working on Ladybug, Butterfly and Dragonfly, The Cricket and SensorTile not yet arrived. Now starting my Sensor-node development experiment, I run in the first barrier:

image

I2c not working. I can't find the core library like with ESP32. Anyway I am not expert in this kind of issues.

Please give my some directions to enter stm32l4 arduino world.

Thanks: Csaba Toth .

kriswiner commented 6 years ago

This is very old syntax. Check the Ladybug or Dragonfly github repositories for more current examples.

Wire.begin(TWI_PINS_20_21); // set master mode, Wire.setClock(400000); // I2C frequency at 400 kHz

On Sat, May 26, 2018 at 12:38 PM, tcsaba101 notifications@github.com wrote:

Dear Kris & Thomas, I have a limited experience in Atmel AVR, ESP32, chipkit PIC development, mainly Arduino, some MPXlab, Atmelstudio + Atmel-ICE platforms. I like Arduino, because of simplicity.

I am kickstarting in STM32 on your platform. Blink was working on Ladybug, Butterfly and Dragonfly, The Cricket and SensorTile not yet arrived. Now starting my Sensor-node development experiment, I run in the first barrier:

[image: image] https://user-images.githubusercontent.com/24205334/40579647-bcb29d3a-612c-11e8-9cfe-4e7287277e1a.png

I2c not working. I can't find the core library like with ESP32. Anyway I am not expert in this kind of issues.

Please give my some directions to enter stm32l4 arduino world.

Thanks: Csaba Toth .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/35, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlQiiVwK5JQNWIukbkdEX49xf6Xzks5t2a8igaJpZM4UPB63 .

tcsaba101 commented 6 years ago

Thanks Kris! Every step looks painful: This is the example code from Adafruit, what compiles without issue on Arduino Mega. Please recommend some 1.3" Oled library what works. I looks that compile as it would be SPI control, but no parameter given, as it is an i2c. image Where the STM32L4 core stays during compilation? It is temporarily generated during arduino setup? Does it works together with the STM32L0 core?

GrumpyOldPizza commented 6 years ago

The use of "portOutputRegister()" and such is sadly utterly importable. AVR uses 8 bit ports, everybody else uses 32 bit ones.

I am not sure where you got your library from, but the original from Adafruit has the proper defines in place, that would uses 32 bit ports for all non-AVR platforms (more or less):

if defined(SAM3X8E)

typedef volatile RwReg PortReg; typedef uint32_t PortMask;

define HAVE_PORTREG

elif defined(ARDUINO_ARCH_SAMD)

// not supported

elif defined(ESP8266) || defined(ESP32) || defined(ARDUINO_STM32_FEATHER)

|| defined(arc) typedef volatile uint32_t PortReg; typedef uint32_t PortMask;

elif defined(AVR)

typedef volatile uint8_t PortReg; typedef uint8_t PortMask;

define HAVE_PORTREG

else

// chances are its 32 bit so assume that typedef volatile uint32_t PortReg; typedef uint32_t PortMask;

endif

On Mon, May 28, 2018 at 2:04 AM, tcsaba101 notifications@github.com wrote:

Thanks Kris! Every step looks painful: This is the example code from Adafruit, what compiles without issue on Arduino Mega. Please recommend some 1.3" Oled library what works. I looks that compile as it would be SPI control, but no parameter given, as it is an i2c. [image: image] https://user-images.githubusercontent.com/24205334/40603904-9d354a5c-625d-11e8-924b-1a3d30260797.png Where the STM32L4 core stays during compilation? It is temporarily generated during arduino setup? Does it works together with the STM32L0 core?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/35#issuecomment-392452021, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfM7h3RvUSgPzZ2NOaP8Kw9qmJaMuks5t2698gaJpZM4UPB63 .

tcsaba101 commented 6 years ago

Thomas you are absolutely right, I have plugged the Adafruit lib from the original source and everything compiled with no issue.

Then it has turned out my Oled from China is not Adafruit compatible. My previous "Adafruit library" was hacked and was handling the fake Oleds, but were not compile on stm32l4 platform. What is compile that is not handling fake parts. Not even worked on Arduino with original library. So I moved to u8g2 library, what is handling many chips.

Found an example with 2 Oled displays, what was running on Arduino well. When changed the platform to STM32L4, I have got a new compiling error: image

dtostrf() is not working here or some other mistake happened?

Thanks, Csaba

GrumpyOldPizza commented 6 years ago

dtostrf() is not part of the Arduino API (nor Standard C Library API).

It's actually part of the Arduino AVR compatibility and you have to use:

include <avr/dtostrf.h>

That's the same with the official Arduino Cores ...

https://forum.arduino.cc/index.php?topic=390276.0 http://forum.arduino.cc/index.php?topic=368720.0 https://forum.arduino.cc/index.php?topic=349764.0

N.b the STM32L0 / STM32L4 cores use code derived from SAMD. Hence it's the printf() based dtostrf() variant, which seems to have some issues.

On Tue, May 29, 2018 at 2:52 AM, tcsaba101 notifications@github.com wrote:

Thomas you are absolutely right, I have plugged the Adafruit lib from the original source and everything compiled with no issue.

Then it has turned out my Oled from China is not Adafruit compatible. My previous "Adafruit library" was hacked and was handling the fake Oleds, but were not compile on stm32l4 platform. What is compile that is not handling fake parts. Not even worked on Arduino with original library. So I moved to u8g2 library, what is handling many chips.

Found an example with 2 Oled displays, what was running on Arduino well. When changed the platform to STM32L4, I have got a new compiling error: [image: image] https://user-images.githubusercontent.com/24205334/40647933-6f4f74d4-632d-11e8-888b-d1605d252a0c.png

dtostrf() is not working here or some other mistake happened?

Thanks, Csaba

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/35#issuecomment-392702436, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfM7dOHVOdkBTW8O6WYdDWXqmmDiMks5t3QxkgaJpZM4UPB63 .

tcsaba101 commented 6 years ago

Thanks Thomas, perfectly works.