Untitled - CLIKE 1.39 KB
                                
                                    #include <stdint.h>
#include <stm32f446xx.h>
#include <system_stm32f4xx.h>

int main(void)
{
	RCC->PLLCFGR &= ~(RCC_PLLCFGR_PLLM_Msk |
	                  RCC_PLLCFGR_PLLN_Msk |
	                  RCC_PLLCFGR_PLLP_Msk);

	RCC->PLLCFGR |= ((8 << RCC_PLLCFGR_PLLM_Pos) |
	                 (180 << RCC_PLLCFGR_PLLN_Pos) |
	                 ( 0 << RCC_PLLCFGR_PLLP_Pos) |
					 RCC_PLLCFGR_PLLSRC_HSI);

	RCC->CFGR &= ~(RCC_CFGR_PPRE1_Msk | RCC_CFGR_PPRE2_Msk | RCC_CFGR_HPRE_Msk);
	RCC->CFGR |= (RCC_CFGR_PPRE1_DIV4 | RCC_CFGR_PPRE2_DIV2 | RCC_CFGR_HPRE_DIV1);

	RCC->CR |= RCC_CR_PLLON;
	while ((RCC->CR & RCC_CR_PLLRDY) != RCC_CR_PLLRDY);

	RCC->CFGR &= ~RCC_CFGR_SW_Msk;
	RCC->CFGR |= RCC_CFGR_SW_PLL;
	while ((RCC->CFGR & RCC_CFGR_SWS_PLL) != RCC_CFGR_SWS_PLL);
	
	SystemCoreClockUpdate();

	RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;

	GPIOA->MODER |= GPIO_MODER_MODE5_0;
	GPIOA->MODER &= ~(GPIO_MODER_MODE5_1);

	GPIOA->OTYPER &= ~(GPIO_OTYPER_OT5);

	GPIOA->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR5_0;
	GPIOA->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR5_1;

	GPIOA->PUPDR |= GPIO_PUPDR_PUPD0_0;
	GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPD0_1);
	while(1)
		{
			for(uint64_t i =0; i < 100000; i++)
			{
			}
			GPIOA->ODR ^= GPIO_ODR_OD5;
		}
}
                                
                            

Paste Hosted With By Wklejamy.pl