cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f407 Discovery 10Mhz Clock Output?

ferhatyol-23
Senior
Posted on March 06, 2014 at 10:42

I want to use STM32F407 with the OV7670 camera. I need to external 10 MHz clock source.

SystemCoreClock 168 Mhz

AHB Prescaler 1, ABP1 Prescaler 4, ABP2 Prescaler 2

Can I get 10 Mhz clock using Timer 3.

#stm32f407 #pwm #timer3
11 REPLIES 11
Posted on March 06, 2014 at 11:15

> Can I get 10 Mhz clock using Timer 3.

No. TIM3's input clock is 84MHz and you can't divide that to 10MHz. You need to change the master clock (HCLK) so that it is an integer multiple of 10MHz, say, to 160MHz.

Other option would be to use the I2S PLL and output it via MCO2 or via master clock output of one of the I2S modules.

JW

ferhatyol-23
Senior
Posted on March 06, 2014 at 11:58

Thanks for the reply. 

I do not have any information about the use of I2S. Is there any example about I2S?

Posted on March 06, 2014 at 13:01

Clive posted this:

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=22578

of course you need to adjust the parameters to fit your needs.

JW

ferhatyol-23
Senior
Posted on March 06, 2014 at 15:13

Thank you for giving me the sample application,

I do not know how to do PLLI2S settings. 

RCC_PLLI2SConfig(192, 5); 

What are the parameters of this function? 

What should be the correct settings for 10MHz signal? How do I calculate the frequency? 

Regards.

Posted on March 06, 2014 at 15:27

It's a function from the Standard Peripheral Library. Go into your copy of it and find it in stm32f4xx_rcc.c; there is a description of what the parameters mean in the header of that function.

Then go to the RCC chapter in RM0090 - the Reference Manual to the STM32F4xx to find out what the parameters to the PLL do.

JW
Posted on March 06, 2014 at 18:47

RCC_PLLI2SConfig(192, 5); // It's a standard library function, review the source if confused.

192 MHz / 5 = 38.4 MHz, with a PLL comparison frequency of 1 MHz

For 10 MHz, I'd probably shoot for 40 MHz (ie 27 - 192 MHz), and have the MCO Div 4

RCC_PLLI2SConfig(200, 5);

200 MHz / 5 = 40 MHz,  40 MHz / 4 = 10 MHz

There are probably dozens of other solutions, but pretty sure this fits. To understand the constraints of the settings you'll have to RTFM
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 06, 2014 at 18:53

// STM32F4 Discovery - MCO2 10 MHz - sourcer32@gmail.com
#include ''stm32f4_discovery.h''
/**************************************************************************************/
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_MCO);
RCC_PLLI2SCmd(DISABLE);
RCC_PLLI2SConfig(200, 5); // .432, 2..7, ie range of 429 Mhz to 192 MHz
RCC_MCO2Config(RCC_MCO2Source_PLLI2SCLK, RCC_MCO2Div_4); // 10 MHz with default PLL fComp
RCC_PLLI2SCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLI2SRDY) == RESET);
while(1); // Don't want to exit
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ferhatyol-23
Senior
Posted on March 06, 2014 at 22:28

@clive1 Thank you

Now that you've run the code But I have a problem.The clock signal comes irregularly.

I get the logic analyzer signal shape is like in the picture.

http://s28.postimg.org/s66ofwl71/Ekran_Al_nt_s.jpg

What causes this problem?
Posted on March 06, 2014 at 22:49

What causes this problem?

The bandwidth of your analyzer is not what it purports to be, increase the sample rate or use a real scope with a 10x probe.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..