Got a weird one - using atsamd-hal 0.23.1 on a Feather M0 and compiling with release optimizations, I see extra transactions on the line between M0 and an SD card, as if the MISO bytes are being delayed by one word. I've verified the issue is in the write_word_by_word call by modifying it to use transfer_word_in_place instead of disabling the receiver, writing data, and then re-enabling the receiver.
Found this issue in the process of tracking down why embedded-sdmmc card intialization worked when compiled in debug mode but failed in release mode. I captured the SPI comms (had to write a new ExclusiveDevice that let me bring the CS line out to an extra pin, since the Feather SD CS line is not accessible) and tried to verify that embedded-sdmmc was deterministic by replaying the conversation, but was finding extra single-word read transactions in my capture. This led me to try modifying write_word_by_word.
Replaced this linked code with what's below, and the SD card finally initialized properly with a release build.
https://github.com/atsamd-rs/atsamd/blob/atsamd-hal-0.23.1/hal/src/sercom/spi/impl_ehal/mod.rs#L155-L171
fn write_word_by_word(&mut self, words: &[Word<C>]) -> Result<(), Error> {
for word in words {
self.transfer_word_in_place(*word)?;
}
Ok(())
}
Anyone else seen anything like this before? I checked the D21 errata but found no mention of any issue with SPI disable.
Edit: another theory, as I hit submit - is it possible that the original write_word_by_word was re-enabling the receiver before the write actually went out, and so was actually receiving the byte it was trying to ignore? That'd suggest that another fix would be to wait for the write to complete before re-enabling.
Got a weird one - using atsamd-hal 0.23.1 on a Feather M0 and compiling with release optimizations, I see extra transactions on the line between M0 and an SD card, as if the MISO bytes are being delayed by one word. I've verified the issue is in the write_word_by_word call by modifying it to use transfer_word_in_place instead of disabling the receiver, writing data, and then re-enabling the receiver.
Found this issue in the process of tracking down why embedded-sdmmc card intialization worked when compiled in debug mode but failed in release mode. I captured the SPI comms (had to write a new ExclusiveDevice that let me bring the CS line out to an extra pin, since the Feather SD CS line is not accessible) and tried to verify that embedded-sdmmc was deterministic by replaying the conversation, but was finding extra single-word read transactions in my capture. This led me to try modifying write_word_by_word.
Replaced this linked code with what's below, and the SD card finally initialized properly with a release build.
https://github.com/atsamd-rs/atsamd/blob/atsamd-hal-0.23.1/hal/src/sercom/spi/impl_ehal/mod.rs#L155-L171
Anyone else seen anything like this before? I checked the D21 errata but found no mention of any issue with SPI disable.
Edit: another theory, as I hit submit - is it possible that the original write_word_by_word was re-enabling the receiver before the write actually went out, and so was actually receiving the byte it was trying to ignore? That'd suggest that another fix would be to wait for the write to complete before re-enabling.