I2C breaks due debug restart

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

AmperCZ
Posts: 15
Joined: Fri Jan 25, 2019 11:46 pm
Been thanked: 1 time

I2C breaks due debug restart

Postby AmperCZ » Thu Jun 18, 2020 5:48 pm

Is there some way how to stop program by debugger in state that will not break i2c ? Or is there some way how to "reset" bus ?

I have two 6050 on I2CD2 (STM32F407) on wires (STD/100kH) and also at24c08 memory on I2C1 directly on pcb (FAST/400)

Problem with 6050 could be fixed by power cycle on them after restart (before I2C is initialized). But recycle power on board is much bigger problem and so it breaks initial load (using that memory for configuration and calibration data).

Do I missing something in ST-LinkV2/OpenOCD usage or it is something what can't be fixed at all ?


Maybe one issue connected to this - what is better ? Set Alternates for I2C in board files or in code itself just before i2cStart ?

mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: I2C breaks due debug restart

Postby mikeprotts » Thu Jun 18, 2020 6:09 pm

When I'm debugging I sometimes have to turn features off and on - I make this an option in the serial console so I don't need a separate debug build normally. After turning off what's not needed, I then interrupt and go into interactive debug mode.

The watchdog is a special case, that's disabled at build time when I'm debugging, otherwise I end up fighting to get control before it resets everything.

If it's only for a custom board, it makes sense to have board.h correctly configured. If you use more than one board, you may be configuring for different builds and then rather than change all the board files. For board definitions already provided, I prefer to use them unchanged so I don't have to remember to reapply changes for a new release (not that the board files seem to change much).

Mike

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C breaks due debug restart

Postby Giovanni » Thu Jun 18, 2020 6:17 pm

If the I2C slave does not have a reset then a power cycle is the only reliable solution.

You may try to send crafted stop sequences using GPIOs but I am not sure it would work for any device.

Another solution would be to not start I2C operations in the first second after reset, that would give the debugger enough time.

Giovanni

AmperCZ
Posts: 15
Joined: Fri Jan 25, 2019 11:46 pm
Been thanked: 1 time

Re: I2C breaks due debug restart

Postby AmperCZ » Fri Jun 19, 2020 8:01 pm

Update - now I believe it is because of some ground issue.

I have board powered from USB, I2C devices are powered from USB 5V on that board.
STLinkV2 is powered from another USB

everything works

but as soon as I connect ftdi or esp8266 powered by third USB (and connected to board by tx/rx/ground) it starts makes issues


Will try to put all 3 usbs into one powered hub to keep them on same power source and will see if it help

AmperCZ
Posts: 15
Joined: Fri Jan 25, 2019 11:46 pm
Been thanked: 1 time

Re: I2C breaks due debug restart

Postby AmperCZ » Fri Jun 19, 2020 8:21 pm

confirmed - powered hub and all 3 usbs from this hub helped


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 48 guests