Shop OBEX P1 Docs P2 Docs Learn Events
Datalogger - getting started with SPI and PIC C — Parallax Forums

Datalogger - getting started with SPI and PIC C

sonocide6sonocide6 Posts: 4
edited 2014-09-21 08:11 in General Discussion
Hi all,

I've got a parallax USB datalogger 27937 with the intention of being able to send some data from my PIC microcontroller to a USB thumb drive via SPI. I am using Microchip's C18 compiler and am fairly well versed in SPI communication.

I'm finding the documentation on how I might get started on this pretty lacking so I'm wondering if anybody can point me in the right direction.

I'm not sure about any procedures I need to follow (open file, write, close file, etc.) or what the SPI messages would be to execute these tasks.

Any help or a link to some example code would be extremely helpful.

Thanks!

Comments

  • kwinnkwinn Posts: 8,697
    edited 2014-09-10 21:00
    All the information is available for download at http://www.parallax.com/product/27937. The Viniculum firmware pdf has all the commands, the data sheet shows how to hook it up, and there some demo code although not in C.
  • sonocide6sonocide6 Posts: 4
    edited 2014-09-11 05:16
    Thanks, I've reviewed the Viniculum firmware pdf but I still don't have a good feel for how I might implement these commands via SPI in C and what process I need to use to successfully write to a file on the USB disk.
  • Mike GreenMike Green Posts: 23,101
    edited 2014-09-11 07:42
    We really can't help you much with code for a non-Parallax microcontroller. A good way to handle this is to translate one or more of the examples in the Parallax documentation into C for the PIC and then get them to work. The Datalogger is a very simple board that just makes the Vinculum chip conveniently available for use with a Stamp or other microcontroller. The details of how to use the chip are in the Vinculum firmware documentation. One important notion is that the data transfer commands require a data byte count. That's a common place for a bug to show up ... supplying an incorrect byte count.

    For the Stamp examples, the Basic Stamp Manual is available online. There's an object in the Propeller Object Exchange that uses SPI mode with the Datalogger. The Propeller Manual is also available online.
  • sonocide6sonocide6 Posts: 4
    edited 2014-09-11 11:29
    The propeller object examples are somewhat helpful. Thanks for pointing me to those. I don't, however, see where in the transfer the byte count shows up.

    I've got functions written for other devices that send discrete bytes or series of bytes to a SPI slave. In the case of the datalogger, do I need to send exactly 12 bits per transfer or can I send 2 bytes with trailing zeros as the four least significant bits?
  • sonocide6sonocide6 Posts: 4
    edited 2014-09-21 08:11
    I've adapted the bit-banging method from the propeller example (the "PRI transfer" function) to C for my project. I am using it to send 12-bit long messages to the datalogger from my PIC; for read:110, then my 8 char bits (MSB first), then a 0, or for write: 100, then my 8 char bits (MSB first), then a 0. According to my logic probe, my timings look acceptable and all of my MOSI data looks correctly formed. I however am never seeing a state change on MISO from the datalogger. (Yes, my jumper is on the SPI side on the datalogger.)

    I'm attempting to send the char 'E", then a CR then read back in the 'E' and a CR. I understand that this is a built in echo function and that it would be a decent way to test my connectivity to the datalogger.

    Please let me know if i'm missing something major here! Mike, can you further explain your earlier "byte count" comment?

    Thanks in advance!
Sign In or Register to comment.