fix: correctly deinit rcc before hse sw

This commit is contained in:
2025-11-10 12:00:21 +06:00
parent 6e29b34542
commit e448282aed
2 changed files with 12 additions and 4 deletions

12
main.c
View File

@@ -29,13 +29,21 @@
struct netif g_netif;
static volatile int g_httpd_is_initialized = 0;
int clock_init(void);
void led_init(void);
void lwip_stack_init(void);
static void set_sysclk_to_120mhz_from_hse(void) {
volatile uint32_t startup_counter = 0;
uint32_t startup_counter = 0;
RCC->INTR = 0x009F0000; // clear PLL, CSSC, HSE, HSI and LSI ready flags.
// switch processor back to HSI so we don't eat dirt.
RCC->CFGR0 = 0;
// disable PLL so we can play with it.
RCC->CTLR &= ~RCC_PLLON;
// not sure why, need to reset here, otherwise PLLXTPRE is set.
RCC->CFGR0 = RCC_PLLSRC;
// enable HSE
RCC->CTLR |= RCC_HSEON;
do {