Advertisement
jaqendax

Peripheral_clock

Dec 8th, 2018
2,893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Includes
  2. #include <stdint.h>                                             //system header
  3. #include "stm32f407xx.h"                  // Non system headers use quotes
  4.  
  5. //main
  6.     int main(void)
  7.     {
  8.         ADC_TypeDef *pADC;          //set the Type as a pointer
  9.         RCC_TypeDef *pRCC;
  10.         pADC = ADC1;                        //make the pointer address the same as ADC1
  11.         pRCC = RCC;
  12.    
  13.         //enable clock 
  14.         pRCC->APB2ENR = pRCC->APB2ENR | (1 << 8);           //set the 9th bit (bit8) to 1
  15.                                                                                                     //or '1 shifted by 8' (starting from bit position 0)
  16.         //access the peripheral register       
  17.         pADC->CR1 = 0x55;                               // -> is 'Member Access' and is used to access the members of pADC(ADC1)
  18.                                                                         //CR! is the 'Control Register 1'
  19.         return 0;
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement