Skip to main content
nickabrham
Associate II
April 21, 2012
Question

RCC_APB1PeriphClockCmd on USART1

  • April 21, 2012
  • 2 replies
  • 1052 views
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
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    April 21, 2012
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    nickabrham
    Associate II
    April 26, 2012
    Posted on April 26, 2012 at 10:54

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

    Thanks.

    Regards,

    Nick.