This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to synchronize two or more MSP430 exactly to one another

Genius 4170 points
Other Parts Discussed in Thread: MSP430F5529, CDCEL925

Hi,

I am wondering if it is possible to have 2 or more MSP430 up and running in synchronization?

My first thought was, that i could start a timer with a high signal on one GPIO pin, than it should already be fairly even, but then the main clock, for example 20MHz would most probably be out of phase.

If i reset both MSP430 and let them reboot I guess there can also be differences, since the two chips are not the same on silicon level.

The reason why I am asking is, I want to generate more than one UART output communication, but I want them to be as close together, on a time basis, as possible, since I want to start and stop or send commands over UART protocol.

I thought I once read something about putting on clock output to another MSP430 clock input or something.

Help or any ideas appreciated :)

Thanks for reading.

cheers.

  • UART is asynchronous by definition. Why would you want to synchronize two msp's then? Thou you can route "master" GPIO (capture compare) signal to timer capture inputs of slave devices, such way you precisely can determine time shift of all the timers. The rest is just proper sync of other functions. Using exactly same circuit you can determine not only phase shift but also estimate frequency difference of all the timer clocks.
  • You must run both chips from the same clock. This can be done by configuring one for an external oscillator, and connect it to the other's MCLK or SMCLK output.

    Startup times after reset will be different, so you indeed need to trigger your code from some GPIO signal to both chips.
  • >You must run both chips from the same clock.
    As he do not specify phase/frequency tolerance, "both chips from the same clock" is not required at all. Especially given fact that UART baud rate is not even specified.
  • OK, thanks for your thoughts, I did have that in mind run one oscillator 24MHz in my case, put the MCLK outon the special function Pins and into the oscillator XT2 pins of the next MSP430, right?

    I dont have any real problem with that, its just in my head for a maybe new project, I want more than one UART connection to the outside world, this would be for music , or midi purposes, lets say I want different outputs, I need one UART for each output, and they gotta be independent from each other, but have to run at the same speed and have the same starts etc...

    MSP430F5529 has only 2 UARTs i can use, so if I want 10 I wanna make sure all MSP430 are running in phase on the same frequency.

    And yes I am perfectly aware that sound wont really care if I have a difference of lets say 1 ms inbetween the synchronization, but why not aim for gold, if I could :)

    If its possible to be very precise and so on, I would like to be that,.


    Thanks again
  • For something as slow as MIDI, you could probably get away with bitbanging a bunch of software UARTs.

    And MIDI allows 1% clock variation; nobody would pay you for doing this work … ;-)

  • what can I say, its for my amusement only :)

    And the only thing I like about microcontrollers are the precise timings when writing own proprietary code with IRQs and stuff. Bitbanging might be suitable, but for that mentioned reason I never done it, probably never will, as long as i can avoid it.
  • >what can I say, its for my amusement only :)

    Seems so - because hardware selection to make 10 MIDI outputs is kinda strange.

    >I did have that in mind run one oscillator 24MHz in my case, put the MCLK outon the special function Pins and into the oscillator XT2 pins of the next MSP430, right?

    Right. Make clock lines short and even then your mileage can vary - output can be too weak to drive 4 parallel inputs. Thou as this is for amusement, you can try first and see how it works. If not - then you need external clock with buffers like cdcel925. Obviously do not hesitate to report here your progress :)

    p.s. For midi hardware 16MHz is more common frequency than 24MHz. When you will configure UART for MIDI baudrate - you will see why.

  • Thanks for your help.

    Actually I never heard or thought of a device like cdcel925, I took a quick look, looks like it splits up the oscillator and I can parallel it that way, not bad.


    Hm I thought the 16MHz had to do with baudrate, but I think 24MHz also has no trouble aligning to this baudrate with an even divider.

    So maybe it will be with the clock pulses or something with notes per quarter, I will find out :)

  • 24 MHz would require a divider that is not a power of two.

    However, whether the MIDI outputs are implemented with the UARTs or emulated with timer outputs, arbitrary dividers are not a problem.

  • Sorry, but  the idea of synchronizing the core clock of multiple MCUs for serial data transfer seems awkward and circumlocutory to me. Separate clocks will inevitably drift away, if you don't have a "tight" and elaborate link between the MCUs.

    I think you need a synchronous serial protocol instead. Other MCUs have USARTs instead of UARTs - they actually feature modes where a synchronizing clock is transferred via a separate line. The MSP430 seems not to support this.

    How about SPI or I2C instead ? Or some protocol with intertwined data/clock signal, like Manchester of Biphase ?

**Attention** This is a public forum