Alfat SDR using I2C

Good afternoon,

I am using an ALFAT-SDR 1.2 card and I have connected it to my host via I2C. I have been able to set the interface mode and then read the banner out of the Alfat processor. Once I have completed that though, I cannot send a command and receive a valid “!00”.
Is there a definitive I2C timing diagram or bit chart to tell me exactly how I should be querying the device?

To read the banner,
I set the start bit for I2c
I write 0xA4 + 1 to the processor
wait for the transmit to finish and look for an Acknowledge from the part
I then read the part in a loop until the data read 0, which means the part has no more data to give, I think.
After the last byte of data, I send a NACK
then send a Stop.

The buffer I gather the banner in reads perfectly every time.

Then I try to send the initialization command: "I M:\n"
Set the start bit
Write the 0xA4 address
wait for the ACK
I then write each individual character of the command (I tried writing it as a string but after getting no where I broke it down to individual chars)
wait for the ACK after each char
restart the I2C
then use the same function as I did for reading the banner. I do not get the correct response. (Although I think once or twice out of 100 times I got the correct answer, though it could have just been the fog of failure playing tricks with my eyes).

So is there somewhere I can get a definitive routine for all the I2C bits and when they should be used?

Thanks for the help.

@ Bad Steve -

“I M:\n” needs time to return error code.

try to use “V\n” command to get firmware version. A delay about 500ms before read error code.

@ Dat

Thanks, I found that out hard way. I put a break point in the routine to check some signals out and when I went back into run mode the correct return code was detected. I put a 100mS delay in and it worked, But it would not work for the command “I D:H\n” (SD Card Reader Mode) So I had to increment it. I used 1 sec and got it to work.
My question now is … Is 500 mS specified somewhere?

I will play some more with my code and see if the 500 mS is a valid number for all of the commands I plan on using. Thanks again for the help.

Steve

@ Bad Steve -

No, it depends on what kind of your media.

Usually initialize a new SD is faster than an old SD.
Also, format a small SD is faster than a big SD.

The way for this is, send the command and read until get error code.