HDK
HDK

Reputation: 1

Can not blink LED connected to Pin A1 STM32F103

I starting to learn stm32 and struggling with this code to blink a LED connected to Pin A1 of STM32F103C8T6. Can someone help me with this. This is my code:

#include <stm32f10x.h>

void SysClockConfig(void)
{
    RCC->CR |= (1 << 16);
    while(!(RCC_CR_HSERDY & RCC->CR));
    
    RCC->APB1ENR |= RCC_APB1ENR_PWREN;
    
    FLASH->ACR |= FLASH_ACR_PRFTBE;
    FLASH->ACR |= FLASH_ACR_LATENCY_2;
    
    RCC->CFGR |= RCC_CFGR_HPRE_DIV1;
    RCC->CFGR |= RCC_CFGR_PPRE1_DIV2;
    RCC->CFGR |= RCC_CFGR_PPRE2_DIV1;
    
    RCC->CFGR |= RCC_CFGR_PLLSRC;
    RCC->CFGR |= RCC_CFGR_PLLMULL9;
    
    RCC->CR |= RCC_CR_PLLON;
    while(!(RCC->CR & RCC_CR_PLLRDY))
    
    RCC->CFGR |= RCC_CFGR_SW_1; 
    while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
}

int main(void)
{
    SysClockConfig();
     
    RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
    
    GPIOA->CRL &= ~(GPIO_CRL_CNF1 | GPIO_CRL_MODE1);
    GPIOA->CRL |= GPIO_CRL_CNF1_0;
    GPIOA->CRL |= GPIO_CRL_MODE1_0;
    
    while(1)
    {
        GPIOA->ODR ^= GPIO_ODR_ODR1;
        volatile uint32_t i;
        for (i = 0; i < 1000000; i++);
    }
}

I don't see anything happened after running this. I did the same with Pin C13 and it worked but not with Pin A1.

Upvotes: 0

Views: 42

Answers (0)

Related Questions