NRF52832 I2C on D6 and D7 crashing

Posted on
  • Hi guys,

    I've made a custom board and installed Espruino (Comiled from GitHub with board NRF52832DK). I've done that before, and everything works fine. However, for this build I changed some pins around, and are using SDA: D6, SCL:D7 for I2C. This time, it causes a lot of troubles:

    If reading or writing on I2C1, it simply crashes.
    If reading or writing using software I2C, it throws "Uncaught Error: I2C Error: Arbitration (start)"

    I looked at the source, and changed the source and noticed in boards/ that D6 is used for serial RX console. I changed that to some other pin, but didn't solve the problem.

    I've spend quite some time and money on the hardware - is there a way to fix this issue through software? I'm out of ideas. Let me know, if more information (debug, code, etc) is needed. My code and build do work on previous prototypes, so I'm quite sure it has something to do with using the pins D6 and D7 for I2C.

  • That's likely your issue - that you get loads of data in on serial when you try and use I2C.

    If the line is high when Espruino starts it assumes Serial is on it and configures it. Best thing would be to change the serial pins in the build but if you manually set the pin modes to 'output' with pinMode first then it should disable serial

  • also try start from different board than NRF52832DK. MDBT42Q may be better choice, reason is NRF52832DK has special support in nordic sdk so some extra stuff gets enabled fot that board that you don't have in your hw, or at least it is safer to disable this¬≠b/master/boards/

  • I've tried setting D6.pinMode('output') in E.setBootCode(), but it doesn't seem to have any effect.

    I also just tried removing the pins from boards/ and building firmware from source. Doesn't seem to have any effect either.

    Oh, and changing the pin physically would be my absolutely the last resort, since it's a custom PCB.

  • I've tried modifying MDBT42Q to the following:

    Espruino works out fine, connects nicely to BLE through NUS, but still gives the above errors.

  • Could it be my crystal / clock? I guess BLE wouldn't work if that were the case.

    I guess I have to pull out my oscilliscope this time.

  • if you don't want serial console set it to EV_BLUETOOTH and comment out console pins and baud rate, if you have button BTN1 that appears to be pressed it will skip code in flash at startup, you may also post code that you are trying to run, don't see it anywhere

    also you may try software i2c instead, just use i2c=new I2C() and then use i2c instead of I2C1, i2c is so simple that you won't gain that much by using hardware i2c

    and btw your pd6 and pd8 pins in get_pins() in board file marked as adc make little sense, on nrf52 only those specific 8 pins can do adc as preset by default

  • My apologizes, I was rushing it in desparation. I've stripped evrything down to minimum,

    Everything runs fine, except that I2C is still not working.

  • do you have pull ups on the pins? 4.7k seems to be typical value. also can you paste your i2c code that is still not working?

  • I pulled out my oscilloscope and debugged the hardware. It turned out that the manufacturer had mounted one component the wrong way around, which caused a current leak. Amazingly nothing was shorted.

    However, I still need to define other pins than D6 and D7 for Serial1 and recompile, which is fine for now.

    Thanks for the help! I definitely learned a lot in the process :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

NRF52832 I2C on D6 and D7 crashing

Posted by Avatar for user125833 @user125833