Advertisement
jaqendax

PC

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