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
AudioPlaySdWav: buffer alignment and irq priority #294
Conversation
merge upstream
…ith lower priority than SDHC DMA in AudioPlaySdWav::play()
the same problem with IRQ and SD.open() occurs in play_sd_raw.cpp |
Pull request updated to cover AudioPlaySdRaw as well. |
Any Idea why it disables the interrupts? |
I'm not sure why interrupts are disabled. my hack was to remove the disable_irq() before SD.open(), and that seemed to work for my testing. https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=207700&viewfull=1#post207700 |
Hm, Paul? |
In this case it is probably better to prevent this in open() |
It might be sufficient to just disable |
This bug arose when the SD lib (SDHC portion) was rewritten to use DMA and DMA interrupt. But the SD logic in NXP_SDHC.cpp just spins on dmaDone for completion. dmaDone is set in the DMA ISR. So another fix would be to change the SD lib to not use DMA ISR, but to spin on the DMA status or SDHC status flag to check for read/write completion. Then no changes would be needed in Audio lib. The previous version of SD lib polled the SDHC status for completion. |
No longer necessary, it's fixed with 6369a6a. |
Currently there are two problems using AudioPlaySdWav together with the latest version of the SD library:
File::read()
has to be 4-byte aligned (see check alignment for DMA buffers SD#17). This PR enforces a 4-byte alignment ofAudioPlaySdWav::buffer
to fix this.AudioPlaySdWav::begin()
disables interrupts completely while callingSD.open()
. As this includes the DMA transfer complete interrupt,SD.open()
never returns (becausedmaDone
is not updated). As a workaround, this PR only disables interrupts with a lower priority thanSDHC_IRQ
.