STM32SD SD.write() doesn't work in the loop?

Post here first, or if you can't find a relevant section!
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

Hi, working with the STM32SD library i'm coming across an error where SD.open() suceeds in making new files but SD.write() returns 0 when trying to write bytes? The SDMMC1 clock is set to 8MHz.

If i run each SD command one after another in setup() it works ok, eg. SD.open() -> SD.write() -> SD.close().
however, when i SD.open() in the setup function, and SD.write() in the loop, it has problems after a while where it doesn't write any bytes at all, i.e. Sd.write() returns 0.

Cheers!
Richard
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

Bump - It looks like it might be conflicting with another devices HAL setup or interrupt priority?
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

Bump - The problem goes away if i disable the HardwareTimer TIM3?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32SD SD.write() doesn't work in the loop?

Post by fpiSTM »

This is possible that IRQ prio can interfere. Up to end user to ensure prio.
https://github.com/stm32duino/wiki/wiki ... ity-values
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

fpiSTM wrote: Wed Feb 03, 2021 12:56 pm This is possible that IRQ prio can interfere. Up to end user to ensure prio.
https://github.com/stm32duino/wiki/wiki ... ity-values
How do i configure these priorities? - The SDMMC doesn't have a interrupt priority?
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

I tried putting "HAL_NVIC_EnableIRQ(SDMMC1_IRQn);" after the TIMER configuration but it didn't do anything.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32SD SD.write() doesn't work in the loop?

Post by fpiSTM »

AFAIK theSTM32SD does not use any interrupt...
My guess is you have a pin mapping issue...
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

fpiSTM wrote: Wed Feb 03, 2021 1:39 pm AFAIK theSTM32SD does not use any interrupt...
My guess is you have a pin mapping issue...
Hmm, it says here it has a global interrupt?

Image
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

If i remove the TIMER configuration completely it works, but the interrupts don't seem to be fixing anything
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Re: STM32SD SD.write() doesn't work in the loop?

Post by Bambo »

Bump - If i change the TIM2 clock speed from 16000 hertz to 1000 hertz it works
Post Reply

Return to “General discussion”