+ Reply to Thread
Results 1 to 20 of 20

Thread: Trying to understand the SPI object.

  1. #1

    Default Trying to understand the SPI object.

    Beau, or anyone... Can someone provide some insight for me on how to use this SPI Engine object? I'm totally lost, not familiar with SPI at all. Googled it to death, and still lost.. My device has the MISO, MOSI, SCK, CSB, and DRDY lines like I see others that I read about... But the object doesn't seem to use the same names for the signals? Dpin,Cpin,SLpin, MSBPRE,LSBPRE,MSBPOST,LSBPOST... ? I can guess that maybe Cpin is the clock... MSB is most significant bit, etc... I never really used shiftin or out for much when using stamps...

    All I want to do is read an 8bitvalue from the device's eeprom at 0x1F.. Maybe later on, expand after I've learned a little about the protocol etc...But I am stumped and at your mercy.

    I guess I should mention I am looking at the demo code below in my attempts..
    Code:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
        #0,MSBPRE,LSBPRE,MSBPOST,LSBPOST                                            'Used for SHIFTIN routines
        #4,LSBFIRST,MSBFIRST                                                        'Used for SHIFTOUT routines
        #0,Dpin,Cpin,SLpin,#8,Bits                                                  'Set Dpin,Cpin,SLpin and Bit constant
        
    VAR     long          DataValue
    OBJ     SPI     : "SPI Engine"
    PUB start
    {
                            Once called from Spin, SHIFTIN or SHIFTOUT remains running in its own COG.
                            If SHIFTIN or SHIFTOUT are called with 'Bits' set to Zero, then the COG will shut
                            down.  Another way to shut the COG down is to call 'stop' from Spin.
    }          
    '------------------------------------------------------------------------------------------------------------------------------
        DataValue := %00011111                                                      'DEBUG - Test value
        SPI.SHIFTOUT(Dpin, Cpin, MSBFIRST, Bits, DataValue)                         'Send SHIFTOUT DataVAlue
        
                                                                                    'DEBUG - Tested with 74HCT164
                                                                                    '        for MSBFIRST and LSBFIRST functions
    '------------------------------------------------------------------------------------------------------------------------------
        dira[23..16] := %11111111                                                   'DEBUG - Make ALL LED's outputs
        dira[SLpin] := %1                                                           'Set Shift / Load pin as an output
        repeat
          outa[SLpin] := %1                                                         'Set Shift / Load pin in shift mode "1"
          DataValue := SPI.SHIFTIN(Dpin, Cpin, MSBPRE, Bits)                        'Get SHIFTIN DataValue
          outa[SLpin] := %0                                                         'Set Shift / Load pin in load mode "0"
          
          outa[23..16] := DataValue                                                 'DEBUG - Lightup the LED's corresponding to the data
                                                                                    '        LED23 = MSB
                                                                                    '        LED16 = LSB

    Post Edited (sharpie) : 12/14/2006 6:37:41 AM GMT
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  2. #2

    Default

    So, I know I am grasping for straws.. But I tried the following and it does nothing impressive for me.. Whatever I put in the shiftout last gets returned, whether the device is present or not.. Not a good sign I'll assume.
    Code:
      repeat
        repeat 10
    '      outa[SLpin] := %1                                                         'Set Shift / Load pin in shift mode "1"
          SPI.SHIFTOUT(4, 5, MSBFIRST, 8, %00101001)                         'Send SHIFTOUT DataVAlue
          waitcnt(100_000+cnt)
          SPI.SHIFTOUT(4, 5, MSBFIRST, 8, %00000101)                         'Send SHIFTOUT DataVAlue
          waitcnt(100_000+cnt)
          DataValue := SPI.SHIFTIN(3, 5, MSBFIRST, 8)                        'Get SHIFTIN DataValue
    '      outa[SLpin] := %0                                                         'Set Shift / Load pin in load mode "0"      
    '      outa[23..16] := DataValue                                                 'DEBUG - Lightup the LED's corresponding to the data
          t.bin(DataValue,8)
          t.str(string(13))
        waitcnt(10_000_000+cnt)
        t.out($00)

    I guess part of what I'm not understanding is how I specify what address and bits I am writing..

    The datasheet provides an example of a read operation as:

    Write 0x29 in direct register ADDPTR (0x02)

    Write 0x05 in direct register OPERATION (0x03)

    Wait 15ms(minimum)

    Read direct register DATARD8 (0x1F), the register content is in bits [7:0]





    Help!!! Please!!!
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  3. #3

    Default

    Sharpie,

    I'm at work, but can give you quick advice. Your eeprom will likely need 4 bytes. 1st is the control, and should at least have "%1010_xxxx", the 1010 part denotes EEproms. The second and third bytes sent are the address bytes of the location you want to read or write. The firth byte is the data you are reading, or writing.

    What hardware (eeprom) are you using?

    I think the I2C object might make it easier. Normally eeproms need to send an ACK bit between the bytes to alert the master (in your case, the Prop) that the previous/last byte was sent and recieved.

    Think about those few important points for a bit. Wikipedia SPI. I was in your boat about 6 months ago, and now I feel like me and SPI are best friends!!! :)

    Someone else will come along here and give you more insight. I need to go scan something on an electron microscope now (never done that before!!)

    -Parsko
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  4. #4

    Default

    I am using a SCP1000 Pressure sensor from VTI Technologies. I agree I2C would be easier, but I could only get ahold of the SPI version...
    I will think about your reply for a bit...
    The datasheet is at http://www.vti.fi/midcom-serveattach...n_rev_0.07.pdf
    Oh and I've wiki'd it, googled it, I think I'm getting more understanding of the protocol.. just not the implementation on the pchip...
    Thanks for your reply Parsko. That is at least more info than I have.. (I'll assume firth is fifth and not first?)
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  5. #5

    Default

    www.mct.net/faq/spi.html

    No, I meant forth.

    Just checked the datasheet. Figure 9. Study that, along with the link above. If you want to bit-bang (write your own communication routine), it's not likely going to be ffigured out overnight.

    You should be able to do this with the shiftout command in the BS2functions library. You only need to send 1 6bit command, and recieve your 8 bit back.

    Again, figure 9 is going to be your friend!!!!

    Success!

    -Luke
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  6. #6

    Default

    Thanks, I actually went over that link earlier.. I'll go over it again in greater detail.. I was afraid you'd say figure 9. I really don't want to write my own comm routing =)
    Table 10 and 11 actually just helped me understand a little more about how it works.. I see now that you (I know I wrote this earlier but now I understand it) write 0x29 in the address 0x02, then write the value 0x05 at address 0x03, wait then read 0x1F.. Which sounds great, but now I need to figure out what you are trying to tell me =) Also, I'm not so bright with the hex/binary tidbits... am I correct in assuming 0x29 = 101001 ????

    Thanks for the input, seriously...
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  7. #7

    Default

    Would something like this be more reasonable?
    Code:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
      SCK  = 5
      MOSI = 4
      MISO = 3
      CSB  = 6
      DRDY = 2
      High = 1
      Low  = 0
      Out  = %1
      In   = %0
        
    VAR
    OBJ
            bs2     : "BS2_Functions"
            tv       : "tv_text"
      
    PUB start
      dira[CSB] := Out
      outa[CSB] := High
      tv.start(12)
      tv.out($00)
      tv.str(string("Pressure Sensor Test",13,13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%10100000,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%11001010,BS2#MSBFIRST,8)
      outa[CSB] := High
      waitcnt(10_000_000+cnt)    
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%11100000,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%10100000,BS2#MSBFIRST,8)
      outa[CSB] := High
      waitcnt(100_000_000+cnt)    
      t.bin(BS2.SHIFTIN(MISO,SCK,BS2#MSBPOST,8))

    I'm a little confused about the order of the bits, fig9 shows the order as A5,A4,A3,A2,A1,A0,RB/W and a Zero, then the Data... And it says the MSB of the words are sent first... My example above proves my ignorance, so I transposed the numbers... and sent MSBFIRST.. Is that wrong?



    Thanks again for the help.. I think I might feel like I'm starting to catch on at least.. at 2.20am... =/
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  8. #8

    Default

    Sharpie,

    You're probably asleep right now. I'll post a few bits now so I can remember later when I'm home...

    In order to recieve data, you must have three BS2.shiftout and one BS3.shiftin commands, for a total of 4 bytes:
    1st. You need to write the control bit first. There are 4 modes, choose one, probably high speed, ($0x03 = %0000_0011)
    When you write, you will end up sending 2 bytes, the first is the OPERATION bit, the second is the data
    So, you would BS3.shiftout the OPERATION bit "$0x03"
    Then you would BS2.shiftout the OPERATION data, for high speed continuous "$0x0A" (%0000_1010)
    2nd. You need to tell it to send you your data, or the 3rd shiftout and 4th shiftin
    Write to the DATARD8 byte: "0x1F" (%0001_1111)
    Then read the data using BS2.shiftin
    Code:
    Okay, here it is a bit simplified:
    Write %0000_0011  (BS2.SHIFTOUT(...,%0000_011_1,...)) (NOTE: bit 7 is the read/write bit, 1 for write)
    Write %0000_1010  (BS2.SHIFTOUT(...,%0001_010_1,...))
    Pause for sometime, don't know how long, maybe zero
    Write %0001_1111  (BS2.SHIFTOUT(...,%0011_111_0,...)) (NOTE: bit 7 is the read/write bit, 0 for read)
    Read     (BS2.SHIFTIN(...))
    
    (You also have the CSB pin and delays to deal with)


    The result you get from the READ step will be your data.

    There are timing issues with this thing, meaning you can't do too much too fast, it seems to want to read at around 1Hz, so if you set it up to do so, that would be best initially.

    From what I read, this seems to be enough to get you reading data. All due respect, you've chosen some tricky hardware to work with.

    I think this is the best I can do for ya!

    -Parsko
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  9. #9

    Default

    Thanks very much Parsko, I am in the office right now but will take all this under advisement and see where it leads.. This is much closer than I was before! I appreciate the input. The sensor is very cool, I knew I was going to have to learn a bit of new stuff.. But I guess I didn't realize the scope! I have tons of incentive to get it to work, it wasn't cheap either..
    Thanks, and I'll let you know if I make any headway! If anyone else has any insight I am all ears!!!

    -thanks
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  10. #10

    Default

    Sharpie,

    The only thing I'm not so sure on is if you actually need to write to the thing to get it to work. It isn't explicit in the datasheet. I'm not sure if you could just let it "warm up" and then you can read stuff in, without the write. Worth a try...

    -Parsko
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  11. #11

    Default

    As in just perform a shiftin accepting the stream of data? I did read somewhere in the datasheet that there are several modes it works in.. In continuous measurement mode (which I am hoping is default but haven't figured out yet) - part 2.2.1.1 around figure4 it says the data is refreshed after each measurement.. and then the DRDY line is set high.. and it halts until you clear the DRDY.. In order to clear it you have to read the pressure output data... And the DRDY must be serviced before the next pressure data update.. =/

    There are apparently other measurement modes, but it looks like you have to configure it to use them.. The triggered mode seems ok, but the module from sparkfun that I bought doesn't give access to the trigger pin.

    I'm going to start working on it now and see what I can find out.. Thanks again!!! It is greatly appreciated.
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  12. #12

    Default

    Ok.. I've reread your suggestion about 50 times.. Tried about 20 iterations of the code.... I think I have the gist better than before. And I apparently misread part of it while in the office earlier...

    But I am totally still stuck on the idea of the order of bits in the words. The Figure9 shows the order as A5, A4, A3, A2, A1, A0, the Read or Write bit, then a zero bit as the LSB....
    In your example, you have first 0000_011_1... for high speed(0x03) Which is 8 bits, and a 1 on the end to indicate write... but what about the 0 bit for LSB? Also, the order.. is it inversed? Should it be 11000010??? Or 00001110?? Since the 7th bit is the read/write and the 8th is a zero bit...??? ACK! I'm confused!!!
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  13. #13

    Default

    The first thing to get is that the BS2.shiftout handles the order of bits in a byte, by setting the BS2#MSBFIRST. Just leave your bit as is in the command, let the command sort out the order. Just make sure you specify MSB first.

    second, long deep breathes!!!

    Oh, and you're totally right, there is an additional bit of "0" for your LSB, sorry. I missed that one. So, shift everything I suggested left(only when writing the operation bits) and add the trailing "0"

    AND, remember, I think you should need 4 commands (unless it can "warm up"). Regardless, for the reading part of it, you'll need two BS2.... commands:

    TO READ THE DATA
    BS2.shiftout(Operation bit)
    BS2.shiftin(data from x-ducer)

    You might want to try a 16 bit shiftin, since the x-ducer seems to like 16 bits. Cover-your-***, so you can't say you didn't try, that's what I do. In the past, I end up trying about 1000 different things, until that one time I get something right. SAVE-AS, perform a revision change, and keep debuggin!!

    I'm no PRO, so i'm not sure that everything I have said is exactly correct, just my interpretation of the datasheet.

    Oh, post some code, keep it simple. Maybe others will be able to help...

    -Parsko
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  14. #14

    Default

    Thanks again.. I took a break, and tried a new approach(which still didn't work).. But I have got more than all zero's back =/ I did try the 16bit return, should prove useful.
    I've been studying your posts, and the code listed in this link http://www.sparkfun.com/datasheets/S...00-Testing.zip
    It's in C and meant for a pic... But it shows good examples of communications with the device. Hasn't helped me figure it out yet, but maybe somebody who knows can see what I'm doing wrong...
    Here's my simplified propeller interpretation..
    Code:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
      SCK  = 5
      MOSI = 4
      MISO = 3
      CSB  = 6
      DRDY = 2
      High = 1
      Low  = 0
      Out  = %1
      In   = %0
        
    VAR
    OBJ
            bs2     : "BS2_Functions"
            tv       : "tv_text"
      
    PUB start
      dira[CSB] := Out
      dira[DRDY] := In
    '  outa[CSB] := High
      bs2.start(20,21)
      tv.start(12)
      tv.out($00)
      tv.str(string("Pressure Sensor Test",13,13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8)  ' ADDPTR Indirect Register Address
      bs2.shiftout(MOSI,SCK,%00101101,BS2#MSBFIRST,8)  ' 0x2D
      outa[CSB] := High
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00000110,BS2#MSBFIRST,8)  ' DATAWR Indirect Register Data
      bs2.shiftout(MOSI,SCK,%00000011,BS2#MSBFIRST,8)  ' 0x03
      outa[CSB] := High
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8)  ' OPERATION Operation Register
      bs2.shiftout(MOSI,SCK,%00000010,BS2#MSBFIRST,8)  ' 0x02
      outa[CSB] := High
      waitcnt(500_000+cnt)
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8)  ' Select High Resolution Mode
      bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8)  ' 0x0A
      outa[CSB] := High
          
    repeat
      repeat while ina[DRDY] == low
      tv.out(00)
      if ina[DRDY] == low
        tv.str(string("LOW",13))
      if ina[DRDY] == high
        tv.str(string("HIGH",13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%01111100,BS2#MSBFIRST,8)  ' 0x1F
      bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8)  ' 0x00
      tv.bin(bs2.shiftin(MISO,SCK,BS2#MSBFIRST,16),16) ' Read next 16bits
      outa[CSB] := High  
      tv.str(string(13))    
      waitcnt(12_500_000+cnt)

    All I get in return from this is 1000000011111111.. I swear, at this point I'd be happy to buy one of these sensors for somebody if they could help me figure this out.!



    Post Edited (sharpie) : 12/15/2006 9:20:32 AM GMT
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  15. #15

    Default

    So, funny thing.. After reading a little more in the datasheet I decided to change the last shiftout and BINGO.. I think I am at least onto something... So I changed the last repeat routine to the following...

    repeat
    repeat while ina[DRDY] == low
    tv.out(00)
    if ina[DRDY] == low
    tv.str(string("LOW",13))
    if ina[DRDY] == high
    tv.str(string("HIGH",13))
    outa[CSB] := Low
    bs2.shiftout(MOSI,SCK,%10000100,BS2#MSBFIRST,8)
    bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8)
    tmp := bs2.shiftin(MISO,SCK,BS2#MSBFIRST,8)
    tv.dec(tmp)
    tv.str(string(13))
    tv.bin(tmp,8)
    tv.str(string(13))
    outa[CSB] := High
    waitcnt(10_000_000+cnt)


    And it is returning some values and seems to be responding to air pressure changes... Although it looks a little jittery and the number it returns doesn't mean anything to me yet (I think it's in Pa, but I have to read more on that...).. Anyway... I know I'm not supposed to be converting all 8 bits to the value and the actual value is somewhere around bit123 or something like that..
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  16. #16

    Default

    In your code above, you only have 3 shiftxxx commands, when (I thinK) you need 4. BUT, if you are getting results, you know you're on to something!!!!! Step one complete. SAVEAS!!!! and onto step 2, figuring out the rest.....

    -Luke
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  17. #17

    Default

    Sorry, I should have posted the whole thing... Here's what I am using to get the results...
    Code:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
      SCK  = 5
      MOSI = 4
      MISO = 3
      CSB  = 6
      DRDY = 2
      High = 1
      Low  = 0
      Out  = %1
      In   = %0
        
    VAR
    OBJ
            bs2     : "BS2_Functions"
            tv      : "tv_text"
      
    PUB start | tmp
      dira[CSB] := Out
      dira[DRDY] := In
    '  outa[CSB] := High
      bs2.start(20,21)
      tv.start(12)
      tv.out($00)
      tv.str(string("Pressure Sensor Test",13,13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00101101,BS2#MSBFIRST,8)
      outa[CSB] := High
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00000110,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00000011,BS2#MSBFIRST,8)
      outa[CSB] := High
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00000010,BS2#MSBFIRST,8)
      outa[CSB] := High
      waitcnt(500_000+cnt)
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%00001110,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8)
      outa[CSB] := High
          
    repeat
      repeat while ina[DRDY] == low
      tv.out(00)
      if ina[DRDY] == low
        tv.str(string("LOW",13))
      if ina[DRDY] == high
        tv.str(string("HIGH",13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%10000100,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8)
      tmp := bs2.shiftin(MISO,SCK,BS2#MSBFIRST,8)
      tv.dec(tmp)
      tv.str(string(13))    
      tv.bin(tmp,8)
      tv.str(string(13))    
      outa[CSB] := High  
      waitcnt(10_000_000+cnt)

    Thanks for the help Parsko.. I'm aboutready to sleep now. =)
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  18. #18

    Default

    Okay, the CSB is your Chip Select, it stays low the whole conversion. So, you toggle it low, send your 4 shiftxxx commands, then toggle it high. This is done so you can share many of these on the same bus, but simply "Chip Select" which one you want to read.

    Also, make your overall waitcnt longer, like 1 second. I remember reading the throughput to be 1.8Hz...

    Why is there 8 SHIFTxxx commands in your loop?

    -Luke
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  19. #19

    Default

    Wait, I see. You have two parts, the first is setting and getting your first read. The second is your read loop. I see why you have the 8 shiftxxx commands now...
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

  20. #20

    Default

    So, after some more tweaking today... It looks like I got something going that is a real value.. However it looks like the following code gives me the temperature.. So, I am closer.. I just have to figure out what I did to read the temp instead of pressure... From looking at the code in that zip file, 0x21 looked like the 16bit LSB pressure value.
    It certainly appears to be temp too, I hold my finger next to the sensor.. the value goes up quick.. pull away and it drops back to around what it was... soldering iron about an inch away drives it up even quicker.. and then back to around 605..
    Here's what I did to get this.. not much different, just different registers and values...
    Code:
    CON
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
      SCK  = 5
      MOSI = 4
      MISO = 3
      CSB  = 6
      DRDY = 2
      High = 1
      Low  = 0
      Out  = %1
      In   = %0
        
    VAR
    OBJ
            bs2     : "BS2_Functions"
            tv      : "tv_text"
      
    PUB start | tmp
      dira[CSB] := Out
      dira[DRDY] := In
    '  outa[CSB] := High
      bs2.start(20,21)
      tv.start(12)
      tv.out($00)
      tv.str(string("Pressure Sensor Test",13,13))
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%000011_10,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00001010,BS2#MSBFIRST,8)
      outa[CSB] := High
      outa[CSB] := Low
      bs2.shiftout(MOSI,SCK,%011111_10,BS2#MSBFIRST,8)
      bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8)
      outa[CSB] := High
      waitcnt(100_000_000+cnt)
          
      repeat
        repeat while ina[DRDY] == low
          if ina[DRDY] == low
            tv.str(string("LOW",13))
        tv.out(00)
        if ina[DRDY] == high
          tv.str(string("HIGH",13))
        outa[CSB] := Low
    '    bs2.shiftout(MOSI,SCK,%100001_00,BS2#MSBFIRST,8)
        bs2.shiftout(MOSI,SCK,%100001_00,BS2#MSBFIRST,8)
    '    bs2.shiftout(MOSI,SCK,%00000000,BS2#MSBFIRST,8)
        tmp := bs2.shiftin(MISO,SCK,BS2#LSBFIRST,16)
        tv.dec(tmp)
        tv.str(string(13))    
        tv.bin(tmp,16)
        tv.str(string(13))    
        outa[CSB] := High  
        waitcnt(100_000_000+cnt)
    Last edited by ForumTools; 10-01-2010 at 03:44 AM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

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