2014-03-06 01:42 AM
I want to use STM32F407 with the OV7670 camera. I need to external 10 MHz clock source.
SystemCoreClock 168 MhzAHB Prescaler 1, ABP1 Prescaler 4, ABP2 Prescaler 2Can I get 10 Mhz clock using Timer 3. #stm32f407 #pwm #timer32014-03-06 02:15 AM
> 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. JW2014-03-06 02:58 AM
Thanks for the reply.
I do not have any information about the use of I2S. Is there any example about I2S?2014-03-06 04:01 AM
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. JW2014-03-06 06:13 AM
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.2014-03-06 06:27 AM
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. JW2014-03-06 09:47 AM
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 RTFM2014-03-06 09:53 AM
// 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
}
2014-03-06 01:28 PM
@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.jpgWhat causes this problem?2014-03-06 01:49 PM
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.