Skip to main content
Paul UHS
Associate III
April 8, 2013
Question

External clock generation at non-multiple of system clock

  • April 8, 2013
  • 22 replies
  • 4052 views
Posted on April 08, 2013 at 09:24

Hi All,

   

I am trying to produce a 256 kHz frequency clock for use with audio codecs. I am trying to produce this 256kHz freq from the 120MHz system clock on the STM32F207 series.

I would like to use the timers to produce this 256kHz clock, however 256kHz does not evenly divide into 120MHz. (120Mhz/256kHz = 468.75)

    

Does anyone know of a way to produce a non-multiple of the system clock by using a combination of timers, and cascading timers.

I have found one way to produce 192MHz from the I2S PLL, and then output on MCO 6.4MHz, which can then be divided down to 256KHz, but this requires two pins, 1 for the MCO pin and 1 for external clock input. I would prefer to be able to just use internal timers and get back two micro controller pins.

Any help find a solution to this would be great.

#fitter #external-clock #advanced-timers #clocks #magic-crystals #doughnuts
This topic has been closed for replies.

22 replies

Paul UHS
Paul UHSAuthor
Associate III
April 9, 2013
Posted on April 09, 2013 at 15:17

It would seem option #2 of using an SPI bus in slave mode works best, rather than using two I2S modules in half duplex.

With two in half duplex, I need to connect FRAME and CLK between the two I2S modules. This requires one more pin (the FRAME Slave pin).

List of pins are:

1) I2S_MASTER_CLK

2) I2S_MASTER_FRAME

3) I2S_MASTER_TX

4) I2S_SLAVE_CLK (connected to I2S_MASTER_CLK)

5) I2S_SLAVE_FRAME (connected to I2S_MASTER_FRAME)

6) I2S_SLAVE_RX

While the pin count using 1 I2S module & 1 SPI module in slave mode:

1) I2S_CLK

2) I2S_TX

3) I2S_FRAME (possibly generated by GPIO via DMA to allow SPI syncronisation)

4) SPI_SLAVE_CLK (connected to I2S_CLK)

5) SPI_SLAVE_MISO

waclawek.jan
Super User
April 10, 2013
Posted on April 10, 2013 at 09:17

> [with USART in synchronous mode] I still keep all the SPI required functionality (albeit at a 10% slow down, but that's fine).

It's not -10% if you are after the highest attainable speeds - while the max. SPI clock is fPCLK/2, the highest USART clock is fPCLK/8, IIRC. So it's more like -90%. Whether this is detrimental in your application, I don't know.

JW