Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ff8640f

Browse filesBrowse files
committed
examples(ADC internal): disable ICACHE if enabled
For some series, calibration values are stored in FLASH read-only area and required to disable ICACHE before access them. Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent b875d3a commit ff8640f
Copy full SHA for ff8640f

File tree

1 file changed

+19
-0
lines changed
Filter options

1 file changed

+19
-0
lines changed

‎examples/Peripherals/ADC/Internal_channels/Internal_channels.ino

Copy file name to clipboardExpand all lines: examples/Peripherals/ADC/Internal_channels/Internal_channels.ino
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ static int32_t readVoltage(int32_t VRef, uint32_t pin)
9393

9494
// The loop routine runs over and over again forever:
9595
void loop() {
96+
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
97+
bool icache_enabled = false;
98+
if (HAL_ICACHE_IsEnabled() == 1) {
99+
icache_enabled = true;
100+
/* Disable instruction cache prior to internal cacheable memory update */
101+
if (HAL_ICACHE_Disable() != HAL_OK) {
102+
Error_Handler();
103+
}
104+
}
105+
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
96106
// Print out the value read
97107
int32_t VRef = readVref();
98108
Serial.printf("VRef(mv)= %i", VRef);
@@ -104,4 +114,13 @@ void loop() {
104114
#endif
105115
Serial.printf("\tA0(mv)= %i\n", readVoltage(VRef, A0));
106116
delay(200);
117+
#if defined(ICACHE) && defined (HAL_ICACHE_MODULE_ENABLED) && !defined(HAL_ICACHE_MODULE_DISABLED)
118+
if (icache_enabled)
119+
{
120+
/* Re-enable instruction cache */
121+
if (HAL_ICACHE_Enable() != HAL_OK) {
122+
Error_Handler();
123+
}
124+
}
125+
#endif /* ICACHE && HAL_ICACHE_MODULE_ENABLED && !HAL_ICACHE_MODULE_DISABLED */
107126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.