fix startHSI48

This commit is contained in:
Edward Emelianov 2019-02-03 10:42:15 +03:00
parent bee695a616
commit 83080900bf
3 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,4 @@
update=Вс 06 янв 2019 17:11:01 update=Ср 30 янв 2019 22:57:36
version=1 version=1
last_client=kicad last_client=kicad
[pcbnew] [pcbnew]

View File

@ -121,18 +121,17 @@ TRUE_INLINE void StartHSE(){
#if !defined (STM32F030x4) && !defined (STM32F030x6) && !defined (STM32F030x8) && !defined (STM32F031x6) && !defined (STM32F038xx) && !defined (STM32F030xC) #if !defined (STM32F030x4) && !defined (STM32F030x6) && !defined (STM32F030x8) && !defined (STM32F031x6) && !defined (STM32F038xx) && !defined (STM32F030xC)
TRUE_INLINE void StartHSI48(){ TRUE_INLINE void StartHSI48(){
// disable PLL RCC->APB1ENR |= RCC_APB1ENR_CRSEN | RCC_APB1ENR_USBEN; // enable CRS (hsi48 sync) & USB
RCC->CR &= ~RCC_CR_PLLON; RCC->CFGR3 &= ~RCC_CFGR3_USBSW; // reset USB
RCC->CR2 &= RCC_CR2_HSI48ON; // turn on HSI48 RCC->CR2 |= RCC_CR2_HSI48ON; // turn ON HSI48
while((RCC->CR2 & RCC_CR2_HSI48RDY) == 0); uint32_t tmout = 16000000;
RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_PLLSRC | RCC_CFGR_PLLMUL)); while(!(RCC->CR2 & RCC_CR2_HSI48RDY)){if(--tmout == 0) break;}
// HSI48/2 * 2 = HSI48 FLASH->ACR = FLASH_ACR_PRFTBE | FLASH_ACR_LATENCY;
RCC->CFGR |= (uint32_t)(RCC_CFGR_PLLSRC_HSI48_PREDIV | RCC_CFGR_PLLMUL2); CRS->CFGR &= ~CRS_CFGR_SYNCSRC;
RCC->CR |= RCC_CR_PLLON; CRS->CFGR |= CRS_CFGR_SYNCSRC_1; // USB SOF selected as sync source
// select HSI48 as system clock source CRS->CR |= CRS_CR_AUTOTRIMEN; // enable auto trim
RCC->CFGR &= ~RCC_CFGR_SW; CRS->CR |= CRS_CR_CEN; // enable freq counter & block CRS->CFGR as read-only
RCC->CFGR |= RCC_CFGR_SW_HSI48; RCC->CFGR |= RCC_CFGR_SW;
while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)RCC_CFGR_SWS_HSI48){}
} }
#endif #endif

View File

@ -0,0 +1,12 @@
/* Linker script for STM32F030f4, 16K flash, 4K RAM. */
/* Define memory regions. */
MEMORY
{
rom (rx) : ORIGIN = 0x08000000, LENGTH = 16K
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 4K
}
/* Include the common ld script. */
INCLUDE stm32f01234.ld