1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

SPI READ and WRITE

Discussion in 'Oshonsoft' started by camerart, Jun 20, 2017.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    I've got tangled up with SPI in Oshonsoft again!
    I recall that when writing to SPI 0X80 must be added, in other words the first bit of the address must have a 10000000.

    I need to READ from on address and WRITE the RESULT to another.
    e,g READ ADDR 0x01 and WRITE the RESULT to ADDR 0x02
    Here is the SPI:
    'SPICSOn
    'SPISend
    'SPICSOff
    'SPICSOn
    'SPISend
    'SPICSOff

    Any clues please?
    Camerart.
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,223
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    You have answered your own query.
    A Write Command on SPI has Bit7 SET to '1' and Read Command has Bit7 set to '0'.

    Is that what you mean.?
    Eric
     

    Attached Files:

  3. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Good morrow, Eric,
    It's a bit more complicated than that, I was getting what I call W_ADDR (WRITE to SPI) mixed up with what I am trying to WRITE to that address. (I hope that's clear?)
    I think I may have figured it out, and I'll let you know post haste :)
    C.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,223
    Likes:
    644
    Location:
    Ex Yorks' Hants UK

    hi C,
    When you are ready, post a working clip of your program and I will check it for you in OSH.
    E
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi e,
    Ok thanks, that would be appreciated.
    I'm translating a program, mentioned in another thread: http://www.electro-tech-online.com/...ion-receiving-using-scr-radio-modules.149198/
    It's blinking complicated, as the SX1278 data sheet is not written in a readable way like a 'HAYNES' manual.
    Cheers, C.
     
  7. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    267
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE
    I have not used SPI, but would'nt SPIsend and SPIreceive take care of the write and read commands ?
    You just provide the address?
     
    • Agree Agree x 1
  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,372
    Likes:
    11
    Location:
    Dorset UK.
    Hi J,
    You would think so, but in this case there is a WNR BIT to add. So 00000000 now = 10000000. From the SX1278 DATA sheet. So I named the addresses for SPI as W_ADDR and I was getting mixed up with WRITE. I'm even getting mixed up explaining it ;)
    I think I've got past this problem now (Time will tell!)
    C.
     

    Attached Files:

    Last edited: Jun 20, 2017

Share This Page