AnsweredAssumed Answered

Synchronize TIMx, SPI1 and SPI2

Question asked by kostka.tim on Feb 13, 2016
Latest reply on Feb 13, 2016 by kostka.tim
I'd like to set up TIM1_CH1, TIM2_CH1, and TIM3_CH1 to be synchronous in the sense that the counters reset to 0 on the same clock tick.  It seems like this is possible using "HAL_TIMEx_MasterConfigSynchronization".


I'd also like to set up the output of SPI1 and SPI2 such that its output is bit-synchronous with these timers.  That is, the first bit begins to be sent as the timers reset to 0.  The output of SPI1 and SPI2 is continuous (driven by circular DMA).  Is there anyway to do this?


Right now, I can sort of synchronize SPI1 to TIM1 by manually setting "TIMx->CR = X" sometime after the SPI transfer begins.  However, I can't get it to be the exact clock edge, and this method is likely to be compiler-dependent anyway.  I don't see a way to synchronize SPI1 and SPI2.


Any guidance would be helpful.  Is there possibly some way to have the HCLK go to sleep while I set things up, then enable it later on to have all peripherals wake up at the same time?


Thanks,
Tim

Outcomes