Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. void delay(int a);
  2.  
  3. int main(void)
  4. {
  5. unsigned int* GPIO_A;
  6. GPIO_A = (unsigned int*)0x40010800 ; // Assigning GPIOA to the correct memory location
  7.  
  8. unsigned int* GPIO_A_CRL;
  9. GPIO_A_CRL = GPIO_A + 0x00 ; // Assigning GPIO_A_CRL to the correct memory location
  10.  
  11. /*unsigned int* GPIO_A_IDR;
  12. GPIO_A_IDR = GPIO_A + 0X08 ; // Assigning GPIO_A_IDR to the correct memory location */
  13.  
  14. unsigned int* GPIO_A_BSRR;
  15. GPIO_A_BSRR = GPIO_A + 0X10 ; // Assigning GPIO_A_BSRR to the correct memory location
  16.  
  17. unsigned int* GPIO_A_BRR;
  18. GPIO_A_BRR = GPIO_A + 0X14 ; // Assigning GPIO_A_BSRR to the correct memory location
  19.  
  20. unsigned int* RCC_APB2ENR;
  21. RCC_APB2ENR = (unsigned int*)(0x40021000 + 0X18) ; // Assigning RCC_APB2ENR to the correct memory location
  22.  
  23. *RCC_APB2ENR = 0X04; // Set clock for GPIOA
  24.  
  25. *GPIO_A_CRL = 0X00008888 ; // Defining pin modes for GPIO_A_CRL
  26.  
  27. while(1) // infinite loop
  28. {
  29. *GPIO_A_BSRR = 0X00000002; // Set bit 1 to 1
  30. delay(2); // delay
  31. *GPIO_A_BRR = 0x00000002; // reset bit 1 to reset value(0)
  32. delay(2); // delay
  33. }
  34.  
  35. }
  36.  
  37. void delay(int a)
  38. {
  39. long b = a*1000000;
  40. for(int i=0;i<b;i++)
  41. {
  42. int c=1;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement