Mac-
Yes, I'm using the AT25640 EEPROM.
I agree that doing this in a function will be easier, and once I prove out the protocol, I'll roll my code into a function or two.
Your idea of sending a byte, ignoring the returned byte, then sending a nulll byte to get the real data byte isn't one I've seen discussed before. I'll add that to my code and see what happens. As to the Read command, I'm going to do this:
When it comes to writing, I'm going to write a similar routine; the code here is just v1.0 and will get additions when I think I know what I'm doing.
Yes, I'm using the mechanical switches on the dev board to trigger the KBI. I think, though, that I'm trapping the KBI well enough that it will only trigger once with each press, regardless of bounce.
Thanks for any other comments,
Rob
Hi Rob,
Register SPID is actually two registers at the same address.
A read gives you the recieved data register
And a write writes to the transmit buffer and then sends it out.
When something is sent something is sent, something is received at exactly the same time. In fact if you just want to recieve you *MUST* send something!!!
In your code for SW1
you do this:
1. wait for txbuf MT
2. send 05
3. wait till its gone and the recieve register is full (same thing)
4. read the SPID **RECEIVE** buffer and load to my_status
my_status will hold some undefined value as you have not told us what is connected to MISO.
For SW2
1. send 03 and ignore what came in
2. send 00 and get recieved byte and do something with it
3. now you hang and trip the COP because the reciever will never get full again unless you send something!!!
P.S. Not sure what your trying to do with your processing of my_status???
BR
Peg
Message Edited by farwestav on 02-16-200608:57 AM