ADIS16250: Help with setting up SPI


Closed Thread
Results 1 to 29 of 29

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    What would be a good pause time? (Note that I am completely new to this)a

  2. #2
    Join Date
    Sep 2006
    Location
    Mexico
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    To obtain clock speed:

    Freq [Hz] = 1/period[seconds]

    Test it with 1 ms (about 1Khz).

    If it doesnt work try with another SPI mode, remember MSB first.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    This is my code:

    <code>
    DEFINE OSC 20
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_SPBRG 21 ' 57600 Bauds
    DEFINE HSER_CLOERR 1
    DEFINE SHIFT_PAUSEUS 1000

    INCLUDE "modedefs.bas"

    Hserout ["ACTIVE",13]

    RST var portd.0
    SCLK var portd.1
    CS var portd.2
    DOUT var portd.3 'data from PIC to Gyro
    DIN var portd.4 'data from gyro to PIC

    temp var word'(2)
    index var word

    High SCLK
    High CS
    high RST

    pause 1000

    main:
    low CS
    Shiftout DOUT, SCLK, 1, [$3C,$00]
    high cs
    pause 100

    low CS
    SHIFTIN DIN, SCLK, 2, [temp\16]
    high CS
    pause 100

    HSEROUT ["Temp: ",HEX4 temp,13]
    pause 100
    goto main
    </code>

    And the output I am getting out is (HEX):

    ACTIVE
    Temp: 0000
    Temp: 0900
    Temp: 0900
    Temp: 0900
    Temp: 0900

    Thanks

  4. #4
    Join Date
    Sep 2006
    Location
    Mexico
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    Is it correct? Does it work?

    Take a look on Table 41 STATUS Bit descriptions (Datasheet pp. 30):

    Address 0x3D, 0x3C
    Default 0x0000
    Default is valid only until the first register write cycle.

    Try reading X-Axis data or another register.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I tried reading the 0x04 register, and it just simply gives me 0x0000. I'm relatively sure my connections are right, but I could be wrong. Do I need any pull-ups? Are there any connections I need other than the SPI, reset, and power connections? Thanks
    Last edited by InitialDriveGTR; - 24th September 2006 at 17:35.

  6. #6
    Join Date
    Aug 2005
    Posts
    57


    Did you find this post helpful? Yes | No

    Default

    I have found that shiftin/out will not work with some devices,its the clock pulse timing I believe.Using the MSSI spi hardware port is an option,more involved though or write your own routine.Below is a sample I used with a Maxim 1270 A/D on a 16F877.

    DataAcquisition:
    for Indexer = 12 to 0 step -1 ' Output data,13 clock pulses
    portc.2 = SerialDataOut.0[Indexer] ' Output data port
    gosub Clockout ' Output clock pulse
    next Indexer ' Next data bit,next clock pulse

    for Indexer = 1 to 12 ' Read data,12 clock pulses
    SerialDataIn = SerialDataIn * 2 ' Shift each bit to the left
    SerialDataIn = SerialDataIn + portc.3 ' Data in port
    gosub Clockout ' Output clock pulse
    next Indexer ' Next data bit,next clock pulse
    return ' Complete return to main

    Clockout: ' Clock pulse
    pulsout portc.0,5 ' Clock pulse port, 1 msec
    return

  7. #7


    Did you find this post helpful? Yes | No

    Default

    With shiftout, how can you use binary format instead of hex? Is there a method for translating binary into hex on the PIC?

Similar Threads

  1. Winbond ISD1700 Voice Recorder
    By RFEFX in forum mel PIC BASIC Pro
    Replies: 58
    Last Post: - 22nd April 2014, 10:00
  2. PICKit2 - warning about configuration words
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 4th August 2009, 14:01
  3. Using SPI with External Interrupts
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 29th June 2008, 04:08
  4. 16-bit SPI problem
    By shaiqbashir in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th June 2008, 15:42
  5. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts