cancel
Showing results for 
Search instead for 
Did you mean: 

RCC_APB1PeriphClockCmd on USART1

nickabrham
Associate II
Posted on April 21, 2012 at 15:14

Hi,

According to the example code provide with the STM32F10x_StdPeriph_Lib_V3.5.0\Project\STM32F10x_StdPeriph_Examples\USART\Interrupt, the clock provided to both the USARTs  i.e.USARTy = USART1 and USARTz = USART2 is through RCC_APB1PeriphClockCmd using the command as in the code below..

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | USARTz_GPIO_CLK | RCC_APB2Periph_AFIO, ENABLE);

  /* Enable USARTy Clock */

  RCC_NVIC_IRQChannelSubPriority(USARTy_CLK, ENABLE);

  /* Enable USARTz Clock */

  RCC_APB1PeriphClockCmd(USARTz_CLK, ENABLE); 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Why is APB2PeriphClock not provided to USART1 e.g. RCC_APB2PeriphClockCmd(USARTy_CLK, ENABLE);?

I am running this example on my STM3210E-EVAL at 72MHz.

bye,

Nick
2 REPLIES 2
Posted on April 21, 2012 at 15:49

void RCC_Configuration(void)

{

  /* Enable GPIO clock */

  RCC_APB2PeriphClockCmd(USARTy_GPIO_CLK | USARTz_GPIO_CLK | RCC_APB2Periph_AFIO, ENABLE);

#ifndef USE_STM3210C_EVAL

 

  /* Enable USARTy Clock */

 

  RCC_APB2PeriphClockCmd(USARTy_CLK, ENABLE);

 

#else

  /* Enable USARTy Clock */

  RCC_APB1PeriphClockCmd(USARTy_CLK, ENABLE);

#endif

  /* Enable USARTz Clock */

  RCC_APB1PeriphClockCmd(USARTz_CLK, ENABLE);

}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nickabrham
Associate II
Posted on April 26, 2012 at 10:54

You are right its #ifndef USE_STM3210C_EVAL.I mistakenly took it #ifdef.

Thanks.

Regards,

Nick.