Question

I'm trying to implement a method to write data to an SD card from a dsPIC33F. 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; it all seems to be 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.

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?

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. I will need at least 2GB of storage, the more the better.

Was it helpful?

Solution

Most SD cards natively support SPI communication but not UART so a direct UART connection isn't possible. I would recommend against the USB flash drive as there is a lot of overhead there that complicates things. 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.

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. Section 11.6 of the datasheet has a good explanation of how to remap pin functions. 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.

OTHER TIPS

SD cards can work with SDIO or SPI.
In order to eliminate the SPI / I2C pin sharing problem, I would:
1) check if the sensor can be replaced with an SPI one
2) if not, I would implement an Software SPI using other pins (the MCU is Master, thus this is much easier)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top