2021-02-21 03:55 AM
I have been told i need to sync 2 STM32 MCU's together (on the same PCB) to stop an intermittent I2C bus failure between them. At the moment they are operating on separate 8Mhz crystals. I have used the following command to configure and output the 8MHz clock on MCO1 (PA8) but it is a square wave and 180 degrees out of phase.
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1);
I am compiling in Atollic.
What have i not done to get an in phase sine wave?
Any help would be appreciated.
2021-02-21 09:57 AM
Tesla and MM Thanks guys for all your help. It is clearly more of an issue in the programming than I assumed. The main thing I can take from this thread is that we do not need to modify the board for a single clock source as that can not be the issue by design. I will halt this thread now as the conversation is moving towards I2C programming issues rather than clock issues. I will look into this a bit more and come back on a different thread when i can describe the issue a lot more thoroughly.
2021-02-21 10:24 AM
Suggested course of action
Instrument both sides of the transaction so you can debug/diagnose the flow. You want to do this independently of the debugger as that can be intrusive.
Have both sides capable of identifying the failing state, via timeout, identify a deadlock, etc allowing you to measure elapsed time and frequency of the issue.
Be able to signal the failure with a GPIO.
Use a logic analyzer to confine signals in a failure state, use the failure signal as a trigger.
Determine which side of the transaction seems to be to blame.
Try to remedy or address what the issue is.
Have the ability to retry or break the deadlock, keep metrics so you can see how often it occurs and the periodicity, check if the issue recurs
2021-02-21 10:38 AM
ok will do Thank you so much for the advice!