Shop OBEX P1 Docs P2 Docs Learn Events
SPI interface how to — Parallax Forums

SPI interface how to

science_geekscience_geek Posts: 247
edited 2009-03-13 02:57 in Propeller 1
i am getting into adc conversion with an mcp3002 and/or the adc0384 i have tried the code from obex for the adc0834 and the sample schematic, i didnt get it to work, i got looking at the code and dont really get how it works, i was wondering if anyone here could give me a quick and dirty example of how SPI works and a sample program that would simulate it

Comments

  • telluriantellurian Posts: 52
    edited 2009-03-13 02:57
    I think you mean an ADC0834 (right?). I have a small driver for it (attached) you can try. I know it works because I use it all of the time. It is for the TLV0834 actually, but that is simply a 3.3V version of the older ADC0834 (a 5V part). Other than that they are identical pin for pin and code for code (a drop in replacement). As far as the SPI goes you are better off learning that on your own because it is too complex to outline in a simple email. In a nutshell it is a synchronous serial protocol that is clocked by a master device (the Prop), control and config bits are streamed to the device via a data out line from the prop, and the results are read in via a data in line on the prop, all synchronized to the clock provided by the master (the prop). There is also a chip enable line that enablee the device for transmission, that way you can have several deices on the data in, out and clock lines but only talk to one at a time. So 4 pins are required for communication via SPI. The specifics of the protocol diverge from there. There is a lot of commonality among devices but there is no single SPI protocol, thus one HAS to read the data sheets to determine the timing and data requirements of each device.

    The attached driver is very simple for the TLV0834 / ADC0834. If you cannot get it to work then you are doing something wrong, I would recommend using the 3.3V part (TLV0834) but the ADC0834 will work too if you put a 1K or 2K resistor in series with the devices Dout (DO) line to the propeller. Note that the pin names in the driver file are with respect to the names of the pins on the TLV0834. Thus 'pin_DI' is the propeller pin that is connected to the DI pin on the TLV0834 / ADC0834.

    If you use an ADC0834 it must be run off of 5V. DO NOT mix up the 5V and 3.3V lines !!! and remember to put a 1k or 2k resistor between the prop and the adc0834 on the adc0834's DO line.

    Good luck,
    tellurian (allen)
Sign In or Register to comment.