Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H7 Fix frozen ADC values #12439

Merged
merged 1 commit into from Mar 3, 2023

Conversation

klutvott123
Copy link
Member

@klutvott123 klutvott123 commented Mar 2, 2023

Fix adc readings not updating on H7 mcus by invalidating the cached adc dma buffer before reading.
The adc dma buffer is in DMA_RAM, and it says here that cache coherency operations are needed for reading, but we're currently not doing it

#ifdef USE_DMA_RAM
{
// DMA transmit buffer in D2 SRAM1
// Reading needs cache coherence operation
.start = (uint32_t)&dmaram_start,
.end = (uint32_t)&dmaram_end,
.size = 0, // Size determined by ".end"
.perm = MPU_REGION_FULL_ACCESS,
.exec = MPU_INSTRUCTION_ACCESS_ENABLE,
.shareable = MPU_ACCESS_SHAREABLE,
.cacheable = MPU_ACCESS_CACHEABLE,
.bufferable = MPU_ACCESS_NOT_BUFFERABLE,
},

Fixes #12419
Fixes #12280

@github-actions
Copy link

github-actions bot commented Mar 2, 2023

Do you want to test this code? Here you have an automated build:
Assets
WARNING: It may be unstable. Use only for testing! See: https://www.youtube.com/watch?v=I1uN9CN30gw for instructions for unified targets!

Copy link
Member

@SteveCEvans SteveCEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot: the comment at line 538 was clearly misleading.

@haslinghuis haslinghuis added this to the 4.5 milestone Mar 2, 2023
Copy link
Member

@haslinghuis haslinghuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lols, Data Cache was disabled on F7 6 years ago:

//HAL_CLEANINVALIDATECACHE((uint32_t*)&adcValues, configuredAdcChannels);

@haslinghuis haslinghuis linked an issue Mar 2, 2023 that may be closed by this pull request
@klutvott123 klutvott123 changed the title H7 ADC buffer invalidate cache H7 Fix frozen ADC values Mar 2, 2023
@klutvott123
Copy link
Member Author

@haslinghuis That line of code has been commented out from the start for F7. The data cache is enabled for F7, but the dma buffers are located in DTCM RAM, and can be directly accessed by the CPU so no manual operations are needed. dma can't access dtcm ram on H7 so we have to do it like this 🙂

@blckmn
Copy link
Member

blckmn commented Mar 2, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> FAIL
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> PASS
  • approver count at least three -> FAIL

@blckmn blckmn merged commit f59b7e7 into betaflight:master Mar 3, 2023
@klutvott123 klutvott123 deleted the h7-adc-invalidate-cache branch March 5, 2023 21:01
davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
H7 ADC buffer invalidate cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

Battery Telemetry Not Updating after 4.4 ADC VBAT values freeze once armed on GH743
4 participants