SPI - The basics


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624

    Default Re: SPI - The basics

    Hi,
    I just took a quick look at this but as far as I can see the commands are 8 bits and the response from the device is 11 bits starting at the 9th clock pulse. So, if reading the acceleration you first SHIFTOUT the 8 bit RDAX command, then you SHIFTIN 11 bits for a total of 19bits.

  2. #2
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231

    Default Re: SPI - The basics

    After banging around for a while, I was able to get this to give me good data from the inclinometer:
    Code:
    CS_I      VAR           PORTD.0  ' chip select Inclinomteter
    CS_D      VAR           PORTC.3  ' chip select D/A
    SCK       VAR           PORTD.3 ' clock
    SDI       VAR           PORTD.2 ' data IN , MISO
    SDO       VAR           PORTD.1 ' data OUT, MOSI
    IncIn     var           word
    HIGH CS_I   
    HIGH CS_D
    LOW SCK
    HIGH CS_I
    'I = %00001000      'send TeMP command
    I = %00010000     'send RDAX 
    
    Main:
         GOSUB iNCrDG
         hserout ["IncRdg ",bin IncIn," ",DEC IncIn," ",10,13]
         PAUSE 100
    goto main
    '**** Subs *********************************
    ;---- Sub to read the inclinometer ------------------
    IncRdg:
      LOW CS_I                       ' enable writes to Inclinometer
      SHIFTOUT SDO,SCK,1,[I]      'sends command to READ
      SHIFTIN SDI,SCK,0,[IncIn\11]  
      HIGH CS_I 
      RETURN
    My LOGIC pod had a bit of a rough time trying to make sense of the unusual length of data and that threw me for a bit, but the HSEROUT showed that all was good. .

    Hope that help someone.

    Bo

Members who have read this thread : 1

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