MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.25k stars 19.23k forks source link

[bugfix_2.0.x] LPC1768 BlinkM wrong I2C- Address #9799

Closed kAdonis closed 5 years ago

kAdonis commented 6 years ago

Bug Report

When I change i2C- Address in blinkm.cpp to 0x12 BlinkM is doing fine.

Wire.beginTransmission(0x12)

So it seems to me, there is a Problem with 7 bit I2C- Adresses (like BlinkM with 0x09) wich are left shifted as stated in BlinkM Datasheet. Just changing the Address to 0x12 breaks compatibility with Arduino, so I think it has to be done in the Hal, which is far beyond my skills

thinkyhead commented 6 years ago

Did you know the address of a BlinkM is configurable? https://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf

kAdonis commented 6 years ago

Yes, I know that. But thats not the Point The default Address 0x09 works with the Arduino mega, but with a ReArm and probably with the STMs its getting 0x12, because the 7bit Address ist left shifted. this will affect all 7 bit Adresses on the I2C bus.

thinkyhead commented 6 years ago

Ah, right. My hex math isn't working today. Thanks for clarifying.

So, you said if you give it 0x12 it works fine. That implies that we should be shifting all our addresses left, so that the BlinkM will see the 0x09 it wants, correct?

Or is it the converse, where our usual 0x09 is being left-shifted on the way out, so that the BlinkM internally gets the 0x12 that it wants, but for STM and others we must do the left shift on its behalf?

thinkyhead commented 6 years ago

Answered my own question with https://community.particle.io/t/i2c-7-or-8-bit-addresses-fixed-pull-request-submitted/1328/9

thinkyhead commented 6 years ago

Our LPC HAL includes this… The address is being right-shifted before send. So it's expecting the left-justified address. Of course, we have control over this one.

uint8_t TwoWire::endTransmission(void) {
  // transmit buffer (blocking)
  I2C_M_SETUP_Type transferMCfg;
  transferMCfg.sl_addr7bit = txAddress >> 1; // not sure about the right shift
    transferMCfg.tx_data = txBuffer;
kAdonis commented 6 years ago

I dont know much about coding, i can´t help you there but the BlinkM works with 0x12 and does not with 0x09

thinkyhead commented 6 years ago

Well it's important that I state these things, because the core HAL developers will be reading this too. Thank you immensely for bringing this to our attention! Should be fixed later today.

kAdonis commented 6 years ago

My pleasure!

boelle commented 5 years ago

@thinkyhead was it fixed?

kAdonis commented 5 years ago

@thinkyhead @boelle Sorry, this was not fixed. I know, it has a low priority and maybe I am the only one still using a BlinkM, but I still need to change I2C adress every time I download marlin

thinkyhead commented 5 years ago

Hopefully this latest patch will take care of it!

kAdonis commented 5 years ago

Dont know, if it's a unicorn, but it is working. Thanks a lot

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.