2
\$\begingroup\$

I am designing a data logging system that uploads its data via 3G.

I'm going to be sampling an I2C sensor at 10Hz, buffering this in local memory (or FRAM), and then dumping the contents of the buffer to an SD card periodically (every few seconds).

Every 15 minutes or so, I want to upload the contents of the file to a web server using a 3G module (Sim5360). I understand that this module can be directly connected to an SD card, and can be instructed to upload files from the SD card. This will take processing effort away from my uC and will increase the upload speed that can be achieved, compared to streaming the data from the uC via the UART.

In order for this to work, both the Sim5360 and the uC need to have access to the SD card, requiring a multi master SPI bus. Is this possible?

As long as both devices have the ability to read and write from the SD card, I can ensure that there are no conflicts by simultaneous attempts to use the resource at the same time.

Please can someone tell me if this is possible and if there is anything special I need to do to make this functional?

Alternatively, if anyone has a better idea on how to achieve this, I'd love to hear it.

\$\endgroup\$
2
\$\begingroup\$

It's not impossible, but you have to be very careful from a software point of view regarding the filesystem on the card. Each device must flush buffers and unmount the card before "releasing" it to the other device.

\$\endgroup\$
  • \$\begingroup\$ There is a limited amount of control over how the SIM5360 interracts with the SD card, as it is controlled via AT Commands on the UART. As a result, do you think that this would cause problems? \$\endgroup\$ – Steve Feb 2 '17 at 14:36
  • 1
    \$\begingroup\$ Potentially, yes, assuming there's a FAT or similar filesystem on the card - the devices will cache different views and files may not show up or overwrite each other. They have to be non-overlapping mounts. \$\endgroup\$ – pjc50 Feb 2 '17 at 14:48
2
\$\begingroup\$

It does not really matter for example if you have two slaves beside the MCU or a slave and a turned off other master. So basically the turned off SIM5360 should not cause any trouble to the MCU given it properly unmounted the SD card before turning itself off, just as @pjc50 has mentioned.

Disconnecting the lines of the SIM5360 by a multiplexer controlled by the MCU is not recommended. It would bring more risk into the system because due to a software bug the MCU might disconnect the SIM5360 while it reads/writes the SD card.

I think you should check two condition by the MCU before accessing the SD card.

  1. Always check if the SIM5360 is properly, entirely turned off.
  2. Check the status of the Slave Select pin of the SD card if it is in high logic state (assuming active low slave select pin).

If either of these conditions are false do not proceed.

\$\endgroup\$
1
\$\begingroup\$

Make Sim5360 "master" for the SD card. So it can get dedicated access to the sd card when needed. This can be achieved using some input pin on the uC that is controlled by Sim5360.

If uC is not able to write its buffered data to the sd card it just needs to buffer longer or throw some data away. If the amount of data is reasonably small, it can even be stored in flash until it can be copied to sdcard.

\$\endgroup\$
  • \$\begingroup\$ I'm not concerned about handling conflict of resource, I just really want to know if the uC will be able to read/write to the SD card while the SIM5360 is turned off? \$\endgroup\$ – Steve Feb 2 '17 at 14:05
  • 1
    \$\begingroup\$ You can connect both devices to the slave (sdcard) given that they do not use the SPI bus at the same time. \$\endgroup\$ – staringlizard Feb 2 '17 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.