RCC_AHB2PeriphClockCmd

-1

I'm beginner in Embedded programming. I'm programming in STM 32F407ZG. While programming the demo codes, i just came across the code RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE); what is this?, explain it.

#include "stm32f4xx.h"
#include "stm32f4xx_rcc.h"

 void delay()
  {
   for(int i=0;i<0x3FF;i++)
     for(int j=0;j<0x3FF;j++);
  }

 void mx_pinout_config(void) 
  {
    GPIOG->ODR     = 0x00000000;    
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
    GPIOF->MODER   = 0X55555555;                         // OUTPUT MODE SELECT 
    GPIOF->OTYPER  = 0x00000000;    
    GPIOF->PUPDR   = 0x00000000;
    GPIOF->OSPEEDR = 0xFFFFFFFF;
    GPIOF->ODR     = 0x00000000;       
  }   

 int main(void)
  {
    mx_pinout_config();
    while (1)
      {
        GPIOF->ODR = 0x0000000F;   
        delay();
        GPIOF->ODR = 0x00000000;   
        delay();
      }
  }
embedded
microcontroller
asked on Stack Overflow Jan 30, 2018 by Prabhaa • edited Aug 3, 2019 by glts

1 Answer

1

STM32F407ZG is a low power device.

In order to save power, the microcontroller is designed in such a way so that whenever any peripheral is required, then its respective bus clock needs to be enabled and then only the peripheral can be used, and after the work of the peripheral is over then the clock must be disabled to save power.

In your case, you want to use GPIOF which resides on ARM high-performance bus1 so RCC_AHB1PeriphClockCmd() enables/disables the clock of AHB1 for GPIOF. RCC stands for reset and control circuitry and controls the clock of the CPU, microcontroller peripherals and various buses on it.

answered on Stack Overflow Jan 30, 2018 by Gaurav

User contributions licensed under CC BY-SA 3.0