简体   繁体   English

在 SPI 模式下使用 SD 卡时,您可以在块读取过程中取消断言 CS 吗?

[英]Can you deassert CS in the middle of a block read when using an SD card in SPI mode?

I have a limited buffer in my microcontroller so rather than read an entire sector, I'm trying to read N bytes from a sector on an SD card, then send those N bytes to a target device (FPGA), then repeat until the whole sector is read.我的微控制器中有一个有限的缓冲区,所以我不是读取整个扇区,而是尝试从 SD 卡上的扇区读取 N 个字节,然后将这些 N 个字节发送到目标设备(FPGA),然后重复直到整个扇区扇区被读取。 In order to do that I have to deassert the chip select (CS) to the SD card and assert the CS to the FPGA.为了做到这一点,我必须将芯片选择 (CS) 置为无效到 SD 卡并将 CS 置为 FPGA。 When I reassert CS on the SD card I can't seem to read any more data from that sector so I'm wondering if by deasserting CS I'm terminating that transaction on the SD card.当我在 SD 卡上重新声明 CS 时,我似乎无法从该扇区读取更多数据,所以我想知道是否通过取消声明 CS 来终止 SD 卡上的该事务。 Can't seem to find CS specs to prove this though.似乎无法找到 CS 规范来证明这一点。

When you first assert CS, the SD card (and every other SPI device I've ever used) expects to start a new transaction.当您第一次断言 CS 时,SD 卡(以及我曾经使用过的所有其他 SPI 设备)期望开始一个新事务。 The clock where CS first asserts is used as a synchronization point, without which it would just be an endless bitstream and would require an alternate synchronization method of some kind. CS首先断言的时钟用作同步点,没有它就只是一个无限的比特流,需要某种替代同步方法。 Specs may not explicitly say that deasserting CS terminates a transaction, but the fact that asserting it starts a new one implies that.规范可能没有明确说取消断言 CS 终止一个事务,但断言它启动一个新事务的事实暗示了这一点。

I think standard capacity SD (SDSC) cards will let you read blocks smaller than 512 bytes.我认为标准容量的 SD (SDSC) 卡可以让您读取小于 512 字节的块。 That will limit what cards you can use, but if that's acceptable then that's an option to consider.这将限制您可以使用的卡片,但如果这是可以接受的,那么这是一个可以考虑的选项。 Otherwise your best bet (without modifying the HW) is probably to just read the block over and over as many times as you need.否则你最好的选择(不修改硬件)可能只是根据需要一遍又一遍地读取块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM