简体   繁体   English

UART转SD卡

[英]UART to SD Card

I'm trying to implement a method to write data to an SD card from a dsPIC33F.我正在尝试实现一种从 dsPIC33F 将数据写入 SD 卡的方法。 I currently can transmit the data via UART to Bluetooth and USB, but I can't find anything online in regards to writing to an SD card via UART;我目前可以通过 UART 将数据传输到蓝牙和 USB,但我在网上找不到任何关于通过 UART 写入 SD 卡的信息; it all seems to be SPI.这一切似乎都是SPI。

I would use SPI, but I'm already using I2C and it seems to be difficult to use both SPI and I2C on the same PIC, due to them sharing pins.使用 SPI,但我已经在使用 I2C,并且似乎很难在同一个 PIC 上同时使用 SPI 和 I2C,因为它们共享引脚。

So, can anyone suggest any information on writing data to an SD card via UART, or maybe a way to use both SPI and I2C concurrently?那么,任何人都可以提出有关通过 UART 将数据写入 SD 卡的任何信息,或者同时使用 SPI 和 I2C 的方法吗?

All I want is some form of storage method, so if someone can suggest another method, maybe EEPROM or USB flash drive, then I'm all ears.我想要的只是某种形式的存储方法,所以如果有人可以建议另一种方法,也许是 EEPROM 或 USB 闪存驱动器,那么我全神贯注。 I will need at least 2GB of storage, the more the better.我至少需要 2GB 的存储空间,越多越好。

Most SD cards natively support SPI communication but not UART so a direct UART connection isn't possible.大多数 SD 卡本身支持 SPI 通信,但不支持 UART,因此无法直接连接 UART。 I would recommend against the USB flash drive as there is a lot of overhead there that complicates things.我建议不要使用 USB 闪存驱动器,因为那里有很多开销,使事情变得复杂。 And EEPROM is likely to use SPI or I2C so you're still left with the problem of having the one set of peripheral pins already in use.并且 EEPROM 很可能使用 SPI 或 I2C,因此您仍然会遇到一组外围引脚已经在使用中的问题。

Your best option given the chip you are using is to use the Peripheral Pin Select feature to map some available pins to be the 4 SPI pins you need.鉴于您使用的芯片,您的最佳选择是使用外设引脚选择功能将一些可用引脚映射为您需要的 4 个 SPI 引脚。 Section 11.6 of the datasheet has a good explanation of how to remap pin functions. 数据表的第 11.6 节很好地解释了如何重新映射引脚功能。 That is probably the easiest solution.这可能是最简单的解决方案。

One other approach you could possibly use is to use the UART to communicate with another PIC that has the SPI pins available but that, too, introduces a lot of extra overhead and complexity.您可能使用的另一种方法是使用 UART 与另一个具有 SPI 引脚可用的 PIC 通信,但这也引入了许多额外的开销和复杂性。

SD cards can work with SDIO or SPI. SD 卡可以与 SDIO 或 SPI 一起使用。
In order to eliminate the SPI / I2C pin sharing problem, I would:为了消除 SPI/I2C 引脚共享问题,我会:
1) check if the sensor can be replaced with an SPI one 1)检查传感器是否可以更换为SPI一个
2) if not, I would implement an Software SPI using other pins (the MCU is Master, thus this is much easier) 2)如果没有,我将使用其他引脚实现软件SPI(MCU是主控,因此这更容易)

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

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