diff --git a/examples/MCOtest/MCOtest.c b/examples/MCOtest/MCOtest.c index 61002a95f00bddce95316a3185e2f353572041fa..eb9d6ef0174882f7cfbc5825d3166a9701bb2cb8 100644 --- a/examples/MCOtest/MCOtest.c +++ b/examples/MCOtest/MCOtest.c @@ -16,7 +16,11 @@ int main() // PC4 is T1CH4, 50MHz Output PP CNF = 10: Mux PP, MODE = 11: Out 50MHz GPIOC->CFGLR &= ~(GPIO_CFGLR_MODE4 | GPIO_CFGLR_CNF4); GPIOC->CFGLR |= GPIO_CFGLR_CNF4_1 | GPIO_CFGLR_MODE4_0 | GPIO_CFGLR_MODE4_1; - + // turn the HSE on + RCC->CTLR |= RCC_HSE_ON; + // Wait till HSE is ready + while(!(RCC->CTLR & RCC_HSERDY)); + while(1) { switch(count) diff --git a/examples/MCOtest/funconfig.h b/examples/MCOtest/funconfig.h index 271177434ebba9b36fab488289d372b5ad74313b..120bcf72bd8c2578f8e6b565498c6179b5f3df7a 100644 --- a/examples/MCOtest/funconfig.h +++ b/examples/MCOtest/funconfig.h @@ -4,8 +4,8 @@ #define FUNCONF_TINYVECTOR 1 #define CH32V003 1 -#define FUNCONF_USE_HSE 1 +#define FUNCONF_USE_HSE 0 #define FUNCONF_USE_HSI 1 -#endif +#endif // _FUNCONFIG_H diff --git a/extralibs/ch32v003_SPI.h b/extralibs/ch32v003_SPI.h index 83e055d9d172b621507ff07470467ce326932d80..0da599a3e1d0ee764de40930ce69002f07e94820 100644 --- a/extralibs/ch32v003_SPI.h +++ b/extralibs/ch32v003_SPI.h @@ -8,7 +8,9 @@ #include<stdint.h> //uintN_t support #include"../ch32v003fun/ch32v003fun.h" - +#ifndef APB_CLOCK + #define APB_CLOCK FUNCONF_SYSTEM_CORE_CLOCK +#endif /*######## library usage and configuration