diff --git a/examples/Peripherals/ADC/Internal_channels/Internal_channels.ino b/examples/Peripherals/ADC/Internal_channels/Internal_channels.ino index 7abcec3..373e8d9 100644 --- a/examples/Peripherals/ADC/Internal_channels/Internal_channels.ino +++ b/examples/Peripherals/ADC/Internal_channels/Internal_channels.ino @@ -20,13 +20,22 @@ #include "stm32yyxx_ll_adc.h" /* Values available in datasheet */ +#if defined(STM32C0xx) +#define CALX_TEMP 30 +#else #define CALX_TEMP 25 -#if defined(STM32F1xx) -#define V25 1430 +#endif + +#if defined(STM32C0xx) +#define VTEMP 760 +#define AVG_SLOPE 2530 +#define VREFINT 1212 +#elif defined(STM32F1xx) +#define VTEMP 1430 #define AVG_SLOPE 4300 #define VREFINT 1200 #elif defined(STM32F2xx) || defined(STM32F4xx) -#define V25 760 +#define VTEMP 760 #define AVG_SLOPE 2500 #define VREFINT 1210 #endif @@ -66,7 +75,7 @@ static int32_t readTempSensor(int32_t VRef) return (__LL_ADC_CALC_TEMPERATURE(VRef, analogRead(ATEMP), LL_ADC_RESOLUTION)); #endif #elif defined(__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS) - return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(AVG_SLOPE, V25, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION)); + return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(AVG_SLOPE, VTEMP, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION)); #else return 0; #endif @@ -84,6 +93,16 @@ static int32_t readVoltage(int32_t VRef, uint32_t pin) // The loop routine runs over and over again forever: void loop() { +#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED) + bool icache_enabled = false; + if (HAL_ICACHE_IsEnabled() == 1) { + icache_enabled = true; + /* Disable instruction cache prior to internal cacheable memory update */ + if (HAL_ICACHE_Disable() != HAL_OK) { + Error_Handler(); + } + } +#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */ // Print out the value read int32_t VRef = readVref(); Serial.printf("VRef(mv)= %i", VRef); @@ -95,4 +114,13 @@ void loop() { #endif Serial.printf("\tA0(mv)= %i\n", readVoltage(VRef, A0)); delay(200); +#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED) + if (icache_enabled) + { + /* Re-enable instruction cache */ + if (HAL_ICACHE_Enable() != HAL_OK) { + Error_Handler(); + } + } +#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */ } \ No newline at end of file diff --git a/library.properties b/library.properties index 3c18ed3..d6ddf7f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duino Examples -version=1.2.2 +version=1.2.3 author=several maintainer=stm32duino sentence=Provides several examples for the Arduino core for STM32 MCUs.