• 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.

SPI READ and WRITE

Status
Not open for further replies.

camerart

Active Member
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.
 

ericgibbs

Well-Known Member
Most Helpful Member
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
 

Attachments

camerart

Active Member
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
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
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.
 

ericgibbs

Well-Known Member
Most Helpful Member
hi C,
When you are ready, post a working clip of your program and I will check it for you in OSH.
E
 

jjw

Member
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.
I have not used SPI, but would'nt SPIsend and SPIreceive take care of the write and read commands ?
You just provide the address?
 

camerart

Active Member
I have not used SPI, but would'nt SPIsend and SPIreceive take care of the write and read commands ?
You just provide the address?
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.
 

Attachments

Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top