Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void delay(int a);
- int main(void)
- {
- unsigned int* GPIO_A;
- GPIO_A = (unsigned int*)0x40010800 ; // Assigning GPIOA to the correct memory location
- unsigned int* GPIO_A_CRL;
- GPIO_A_CRL = GPIO_A + 0x00 ; // Assigning GPIO_A_CRL to the correct memory location
- /*unsigned int* GPIO_A_IDR;
- GPIO_A_IDR = GPIO_A + 0X08 ; // Assigning GPIO_A_IDR to the correct memory location */
- unsigned int* GPIO_A_BSRR;
- GPIO_A_BSRR = GPIO_A + 0X10 ; // Assigning GPIO_A_BSRR to the correct memory location
- unsigned int* GPIO_A_BRR;
- GPIO_A_BRR = GPIO_A + 0X14 ; // Assigning GPIO_A_BSRR to the correct memory location
- unsigned int* RCC_APB2ENR;
- RCC_APB2ENR = (unsigned int*)(0x40021000 + 0X18) ; // Assigning RCC_APB2ENR to the correct memory location
- *RCC_APB2ENR = 0X04; // Set clock for GPIOA
- *GPIO_A_CRL = 0X00008888 ; // Defining pin modes for GPIO_A_CRL
- while(1) // infinite loop
- {
- *GPIO_A_BSRR = 0X00000002; // Set bit 1 to 1
- delay(2); // delay
- *GPIO_A_BRR = 0x00000002; // reset bit 1 to reset value(0)
- delay(2); // delay
- }
- }
- void delay(int a)
- {
- long b = a*1000000;
- for(int i=0;i<b;i++)
- {
- int c=1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement