|
|
![]() :: Research Group Embedded Interaction :: Media Informatics :: Ludwig-Maximilians-University Munich Particle MMC Card ReaderPlease see our Particle How-To page and our Particle Software page as well.
Software SPIThe MultiMediaCard (MMC) is connected to the particle via a breakout board which makes every line of the conan inter-board connector accessible. The MMC supports two different modes of data transmission:
The SPI (Serial Peripheral Interface) is an interfacespecfiction for synchron data transmission and reception simultaneously. In most cases three or four lines are needed (controller view):
Despite the PIC18LF6720 controller on the Particle has such an interface built-in and there exist various convenient
functions in the library of the CCS C-Compiler dealing with this issue, it is unfortunately not possible to use these amenities. The reason
for this is the fact that the Hardware-SPI of the controller is one possible mode of the Master Synchronous Serial Port
(MSSP) Module of the PIC. The other mode is I2C. These two modes are exclusively usable because they use the
same pins and the MSSP can only operate in exactly one mode. On the particle, the MSSP is configured as an
I2C-Interface due to the need of communicating with an external serial memory. ATTENTION!! If you use a display AND the MMC on the same particle, it is possible to connect ONLY ONE display, because the data lines of the other five displays are used as the SPI-connection to the MMC. Voltage level need not to be adapted, because the MMC is driven at the same voltage as the particle computer.
Having connected the MMC correctly, you only have to call mmc_read_block() and mmc_write_block(). (jump to top) Software SPI - MeasurementsHere are some printed oscilloscope screens of measurements taken during the reset and init as well as the startsequence
of read and write. Following Measurements show the communication of the particle and the MMC using sofware-emulated SPI.
The line "Data" corresponds to SDO of the PIC.
Then the card needs normally one complete cycle (8 clocks) to process the command. It answers in the next clockcycle. Data on the lines SDO/SDI is accepted by the card/PIC with rising edge of the clock on the CLK-line.
If you encounter problems concerning the communication, just take a single PIC with SPI and try to get the communication working with the built-in hardware-SPI of the controller. We have taken a few screenshots of the communication via the built-in interface which you can find here. You will also have to take a look at this document, if you want to examine the timing of the signals on the four lines more precisely. Software SPI - Files - Code and HeadersThe Code for the communication will be placed here soon. We just have to make some modifications. Hardware SPIThe MultiMediaCard (MMC) is connencted to the PIC via four lines of the SPI described here You just have to look up in the datasheet the corresponding pins for your PIC. Before you can use the hardware interface, you have to configure the SPI of your PIC. You can use the function setup_spi() which is delivered with the CCSC-Compiler, but you additionally have to set two bits of the
control registers SSPSTAT and SSPCON1 of your PIC. Look in the file mmc.c and there in mmc_init() to get the idea
of managing this. Then you are able to communicate simply with the two functions spi_write() and spi_read(). #define SPI_MODE 0 Be careful with the voltage level!! If you supply your circuit with 5V you have to adapt the voltage, because MMCs like only 3,3V. Having connected the MMC correctly, you only have to call mmc_read_block() and mmc_write_block(). (jump to top) Hardware SPI - MeasurementsHere are some printed oscilloscope screens of measurements taken during the reset and init as well as the startsequence
of read and write. Following measurements show the communication of a PIC and the MMC using the built-in SPI.
The line "Data" corresponds to SDO of the PIC.
Then the card needs normally one complete cycle (8 clocks) to process the command. It answers in the next clockcycle. Data on the lines SDO/SDI is accepted by the card/PIC with rising edge of the clock on the CLK-line made clear with the dashed line on the first picture.
If your problems are still not solved, or you have found a mistake or other hints you want to tell us, just contact us. Hardware SPI - Files - Code and HeadersThe Code for the communication will be placed here soon. We just have to make some modifications. Files
References
|
||||||||||||||||||||||||||||||||||||